Code Monkey home page Code Monkey logo

Comments (6)

side777 avatar side777 commented on June 13, 2024

with CSS media queries: http://www.w3schools.com/cssref/css3_pr_mediaquery.asp

from wp-tevko-responsive-images.

jaspermdegroot avatar jaspermdegroot commented on June 13, 2024

@sensaetions

This test gives you insight in how to prevent multiple requests when using CSS media queries: http://timkadlec.com/2012/04/media-query-asset-downloading-results/
If you need to write the CSS in your functions.php (so you can use PHP to generate the URLs), you can use wp_add_inline_style to add it in a style block in the head.

from wp-tevko-responsive-images.

jgraup avatar jgraup commented on June 13, 2024

I'm looking for a background-image solution as well.

Based on this Fiddle;
http://jsfiddle.net/trixta/bfqqnosp/embedded/result/

It might be possible with lazysizes + ls.bgset.min.js plugin:
https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/bgset

from wp-tevko-responsive-images.

jaspermdegroot avatar jaspermdegroot commented on June 13, 2024

Be aware of the "lazy" part of the Lazysizes plugin. In other words, it's not only about responsive images but also about lazy loading.
You could indeed make it work with that JS plugin if you add some filters to replace the srcset and sizes attributes by data-bgset and data-sizes and to add the lazysizes class.
There is also the wp-lazysizes WordPress plugin which has as goal to work seamlessly with this plugin. Maybe it is going to take care of replacing the attributes, but that's more a topic for that repo.

I think background images on itself is outside the scope of this Responsive Images plugin, so I would suggest to close this ticket.

from wp-tevko-responsive-images.

jgraup avatar jgraup commented on June 13, 2024

Currently this plugin does a great job supplying the needed sizes for srcset and sizes. Would it be possible to just add a function to output the data-bgset? Regardless of lazysizes or any other plugin?

from wp-tevko-responsive-images.

tevko avatar tevko commented on June 13, 2024

Hey all, while I definitely see the use case for a responsive background image, I think it's a bit outside of the scope for this plugin. You can add some logic to your functions.php file by making use of the tevkori_get_srcset_array( ) function, which will return all of the necessary image sizes, which should set you up for automatic background size wrangling.

from wp-tevko-responsive-images.

Related Issues (20)

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.