Forums

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
    Posts
  • #149806
    eatenbymonsters
    Participant

    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?

    #149863
    Alen
    Participant

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

    http://wordpress.stackexchange.com/questions/5568/filter-to-remove-image-dimension-attributes

    #149878
    eatenbymonsters
    Participant

    Worked a charm; many thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.