• Please look into the PHP code and advice how to get Dimension details of Thumbnail image?

    <?php if( get_post_meta($post->ID, "Thumbnail", true) ): ?>
    
    				    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;height="150" width="150;" src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>
    
    				<?php else: ?>
    
    				   	<a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
    
    				<?php endif; ?>

    The current code doesn’t display dimension details and I’m getting “Specify image dimension” error in gtmetrix page performance check.
    https://gtmetrix.com/reports/www.geekyard.com/GGRD7130

Viewing 4 replies - 1 through 4 (of 4 total)
  • You forgot to close the style attribute.
    Try this on line 2:

    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" height="150" width="150" src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>

    Thread Starter Geekyard

    (@geekyard)

    Hi Julian,

    I tried your code but still getting “Specify image dimension” error in gtmetrix page performance check.

    Could you please help me with getimagesize function and modify the following code?

    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" height="150" width="150" src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>

    I suppose that may solve the issue.

    try “thumbnail” rather than “Thumbnail”

    Thread Starter Geekyard

    (@geekyard)

    Hi Derweili & Susan thanks for your help.

    The following code provided by Derwili works:

    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" height="150" width="150" src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>

    I cleared W3TC Plugin Caches to reflect this in my blog.

    Thanks it fixed my problem.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to get Thumbnail Dimension?’ is closed to new replies.