332 posts
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
  • Elite Author: Sold more than $75,000 on Envato Market
+4 more
CadenGrant says

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:

<?php
$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]; ?>" />
<script>
responsiveEnhance(document.getElementById('responsive-image'), 400);
</script>

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!

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by