GithubHelp home page GithubHelp logo

Generate image as background url about angular HOT 4 OPEN

imgix avatar imgix commented on May 27, 2024
Generate image as background url

from angular.

Comments (4)

sherwinski avatar sherwinski commented on May 27, 2024

Hey @lcottingham and thanks for the question,.
You could generate a URL using https://github.com/imgix/js-core 's _buildURL and _buildSrcSet functions and pipe that into the background-image property of a component. Were you looking to implement this yourself or hoping for a separate component in this library that fits this use case?

from angular.

lcottingham avatar lcottingham commented on May 27, 2024

@sherwinski thanks for getting back to me 👍
Yes, very true - I could. Ideally, I was looking for a separate component in this library to fit the use case. It just could be a simple bool parameter (something like imgIxBackgroundUrl) that is added to help direct the component logic. For now, I have written a generic quick and dirty method to build the URL that I can pipe into, but it's in no way perfect.

Incorporating the js-core API methods into this package would be helpful. Yes, I could install both but i'd still have to declare two different ImgIx clients to do a very similar job. This isn't really ideal for me.

Could we look at expanding the capability slightly to recognise even just a <div> tag?

Currently we have:
<img ixImg path="examples/pione.jpg" sizes="100vw" />

What about if we have? (just like we have disableVariableQuality)
<div ixImg path="examples/pione.jpg" sizes="100vw" imgIxBackgroundUrl>...</div>

The output of this would be:
<div style="background-image:url('https://imgixsrc.net/path?qryParams...')">...</div>

from angular.

sherwinski avatar sherwinski commented on May 27, 2024

@lcottingham Totally agree that having dedicated component/logic for handling this would be most ideal. And I think that something like your suggested approach could work for those purposes.
I've made a note of this in our backlog but unfortunately can't commit to a timeline as our team is pretty heads-down working on other projects at the moment. For now I'll keep this issue open and post any updates here as they happen.

from angular.

lcottingham avatar lcottingham commented on May 27, 2024

Perfect - I can work with my workaround for now 👍

from angular.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.