Expose the WordPress “img src” part from the get_the_post_thumbnail, to modify the “img src” syntax.
Instructions
Add the following code to your functions.php
file of the theme you wish to use the custom image sizes for.
<?php
$imgs = get_the_post_thumbnail($post->ID);
/*get the img URL, delete the <img /> tag */
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $imgs, $matches);
/*the image URL*/
$img = $matches [1] [0];
/*echo the full img*/
echo '<img src="' . $img . '" alt="" />';
?>
*note, for adding complimentary markup, classes and ID’s, you can do so by using regular expressions such as class="img-responsive"
Comments