0

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.

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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