332 posts
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Became a Top 20 Author of the Month
  • Made it to the Authors' Hall of Fame
+5 more

So I’m working on a new theme, and I’m having trouble getting the images to be responsive.

I tried using this script, but for some reason cannot get it to work: https://github.com/joshje/Responsive-Enhance

More info on this method: http://keirwhitaker.com/archive/automatic-responsive-images-in-wordpress/

I have:

$thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium');
$full = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
<img id="responsive-image" alt="<?php the_title(); ?>" src="<?php echo $thumb[0]; ?>" data-fullsrc="<?php echo $full[0]; ?>" />
responsiveEnhance(document.getElementById('responsive-image'), 400);

And yes, I enqueued the .js file and it is working correctly.. yet it’s not loading the correct image size.

Does anybody have any idea what I might be doing wrong? Or maybe there’s another better way to do responsive images in WP themes? I just want to make sure that I don’t use a responsive solution that loads the full resolution image on mobile devices or tablets instead of a smaller version..

Any help would be greatly appreciated!