Support » Plugin: Simply Instagram » [Plugin: Simply Instagram] PATCH: Save bandwidth for small images in the widget

  • Resolved AndrewLeCody

    (@andrewlecody)


    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/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Simply Instagram] PATCH: Save bandwidth for small images in the widget’ is closed to new replies.