0

I am using Aqua resizer to resize thumbnail on my loop. More flexible than using thumbnail from WordPress. The problem is, image result by Aqua Resizer's has no width and height pixel. The are missing width and/or height attributes. It's decrease the load speed as shown by GTmetrix.

Here my code to call the image on the loop:

 <?php $thumb = get_post_thumbnail_id(); 
    $img_url = wp_get_attachment_url( $thumb,'full' ); 
    $image = aq_resize( $img_url, 150, 200, true, true, true ); 
 ?>
 <img src="<?php if($image) { echo esc_url($image);
 } else {
 echo catch_that_image();} ?>" alt="<?php  echo get_bloginfo('name'); ?>"/>

Would really appreciate your help.

Thank you.

  • if you ask for a 150x200 image, isn't it exactly the size you going to get? – Mark Kaplun Apr 7 '16 at 20:14
  • Yes, I get 150 x 200 (not150px x 200px), but when when test on GTmetrix it's missing width and/or height attributes. Affect to page load speed. – Mailmulah Apr 7 '16 at 20:18
  • you know the width and the height, so why don't you just add it there yourself? – Mark Kaplun Apr 7 '16 at 21:09
  • Not a simple as that, the re-size process by HTML. That make the load slower. – Mailmulah Apr 7 '16 at 21:14
  • Not sure what are you talking about now. You knwo the width is 150 and the height is 200 so add it as attributes? And no, it doesn't make "whatever" slower but I prefer not to open that can of worms. – Mark Kaplun Apr 7 '16 at 21:17
0

So what's wrong with adding in the attributes as Mark is saying?

<?php $thumb = get_post_thumbnail_id(); 
   $img_url = wp_get_attachment_url( $thumb,'full' ); 
   $image = aq_resize( $img_url, 150, 200, true, true, true ); 
?>
<img src="<?php if($image) { echo esc_url($image);
} else {
echo catch_that_image();} ?>" width="150" height="200" alt="<?php  echo get_bloginfo('name'); ?>"/>
| improve this answer | |
  • look like fixed some issue on test by GTmetrix. Will check for other issue. Thank you. – Mailmulah Apr 8 '16 at 4:59

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.