The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Responsive WordPress Featured Image

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #149806

    I have a little image slider where the images are nicely responsive, but I’d like to serve them dynamically using WP’s Featured Image option. The trouble is, WP forces the size of the Featured Image.

    Currently the images are CSS backgrounds styled like this:

    .slider-image{ background-image:url('the-image.svg'); background-position:center; background-size:100%, auto; }

    I’d rather call the image in PHP like this:

    if ( has_post_thumbnail() ) { the_post_thumbnail(); }

    …but still be able to style it with the same width:100%, height: auto; options.

    It’s been driving me crazy for ages; anyone out there already solved this problem?


    You can use a filter to remove the width/height attributes.


    Worked a charm; many thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.