WordPress.org

Ready to get started?Download WordPress

Forums

Simply Instagram
[resolved] PATCH: Save bandwidth for small images in the widget (3 posts)

  1. AndrewLeCody
    Member
    Posted 2 years ago #

    Google PageSpeed pointed out that the images I had set to 125px were originally 306px. This patch makes the widget use the "thumbnail" size for the source image instead of "low_resolution" when the image size is 150px or smaller. This will save decent amount of bandwidth per picture, my PageSpeed went from 85/100 to 90/100 with just this change.

    Index: simplyInstagramFunctions.php
    ===================================================================
    --- simplyInstagramFunctions.php	(revision 571605)
    +++ simplyInstagramFunctions.php	(working copy)
    @@ -84,7 +84,11 @@
     			$output .= '<div class="content-info"><img src="' . plugins_url('/simply-instagram/images/instagram-like.png') . '" width="19px" style="vertical-align: middle;" /> ' . $data['data'][$i]['likes']['count'] . '</div>';
     			$output .= '<div class="content-info"><img src="' . plugins_url('/simply-instagram/images/instagram-comment.png') . '" width="19px" style="vertical-align: middle;" /> ' . $data['data'][$i]['comments']['count'] . '</div>';
     			$output .= '<br/><br/><br/><br/></div>';
    -			$output .= '<img class="front-photo" src="' . $data['data'][$i]['images']['low_resolution']['url'] . '" width="' . $width .'px" title="' . $data['data'][$i]['caption']['text'] . '">';
    +			if ($width <= 150) {
    +				$output .= '<img class="front-photo" src="' . $data['data'][$i]['images']['thumbnail']['url'] . '" width="' . $width .'px" title="' . $data['data'][$i]['caption']['text'] . '">';
    +			} else {
    +				$output .= '<img class="front-photo" src="' . $data['data'][$i]['images']['low_resolution']['url'] . '" width="' . $width .'px" title="' . $data['data'][$i]['caption']['text'] . '">';
    +			}
     			$output .= "</a>";
    
     			echo $output;

    http://wordpress.org/extend/plugins/simply-instagram/

  2. rollybueno
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks Andrew,

    Applied these patches( including the other one ) on v1.2.2

    Cheers!

  3. AndrewLeCody
    Member
    Posted 2 years ago #

    Awesome, I'm glad I could help. I've marked the threads as resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.