From fdf86cec987db8bd6a1b19e9c9e5891523808a80 Mon Sep 17 00:00:00 2001 From: Neoseifer22 Date: Sat, 5 Dec 2015 11:03:29 +0100 Subject: [PATCH 1/2] Improve get_image_markup() in order to get the most optimized size from Instagram for the given width. Improve web performances, especially if thumbnail size (150x150) is returned instead of standard size (612x612). --- inc/shortcodes.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/inc/shortcodes.php b/inc/shortcodes.php index 3a7802a..f4c074a 100644 --- a/inc/shortcodes.php +++ b/inc/shortcodes.php @@ -199,6 +199,17 @@ private function get_image_markup( $feed, $width, $size, $wrapper, $link ) { break; } } + else { + if ( $width <= $image->images->thumbnail->width ) { + $url = $image->images->thumbnail->url; + } + else if ( $width <= $image->images->low_resolution->width ) { + $url = $image->images->low_resolution->url; + } + else { + $url = $image->images->standard_resolution->url; + } + } // Fix https $url = str_replace( 'http://', '//', $url ); @@ -253,4 +264,4 @@ public static function get_instance() { return self::$instance; } -} \ No newline at end of file +} From 9cb4768170aeb7332fa835934395406f3bed1a05 Mon Sep 17 00:00:00 2001 From: Neoseifer22 Date: Sat, 5 Dec 2015 11:07:16 +0100 Subject: [PATCH 2/2] Update shortcodes.php --- inc/shortcodes.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/inc/shortcodes.php b/inc/shortcodes.php index f4c074a..f6812ab 100644 --- a/inc/shortcodes.php +++ b/inc/shortcodes.php @@ -200,16 +200,16 @@ private function get_image_markup( $feed, $width, $size, $wrapper, $link ) { } } else { - if ( $width <= $image->images->thumbnail->width ) { - $url = $image->images->thumbnail->url; - } - else if ( $width <= $image->images->low_resolution->width ) { - $url = $image->images->low_resolution->url; - } - else { - $url = $image->images->standard_resolution->url; - } - } + if ( $width <= $image->images->thumbnail->width ) { + $url = $image->images->thumbnail->url; + } + else if ( $width <= $image->images->low_resolution->width ) { + $url = $image->images->low_resolution->url; + } + else { + $url = $image->images->standard_resolution->url; + } + } // Fix https $url = str_replace( 'http://', '//', $url );