WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the script below, I need to get the URL path to the "medium" size image in the "data-responsive" attribute. Its currently returning the thumbnail size.

the_post_thumbnail("thumbnail", 
    array(
        'itemprop' => 'image',
        'class' => 'alignleft', 
        'style' => 'margin:5px 15px 10px 0;', 
        'data-responsive' => wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID),'medium')
        )
    );

I want the thumbnail used as the default image, however, I need to write the URL to the medium sized image so that I can use that in media queries to swap the image to higher res on larger devices.

share|improve this question
up vote 2 down vote accepted

wp_get_attachment_thumb_url() does not accept size as argument.

You might be looking for wp_get_attachment_image_src(), but I am not sure on top of my head - too many functions in that corner.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.