From 9333f2635f78f8e80f054a9716d106469a41aa17 Mon Sep 17 00:00:00 2001 From: Lukas Gaechter Date: Wed, 17 Aug 2016 14:05:21 +0200 Subject: [PATCH 1/4] Fix return param type --- lib/Timmy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Timmy.php b/lib/Timmy.php index d5f9bcb..00da6c7 100644 --- a/lib/Timmy.php +++ b/lib/Timmy.php @@ -278,7 +278,7 @@ public function filter_image_downsize( $return = false, $attachment_id, $size ) * * @param mixed $timber_image The ID of the image, an array containing an ID key or * an instance of Timber\Image. - * @return \Timber\Image Instance of Timber\Image. + * @return mixed Instance of Timber\Image. */ public static function get_timber_image( $timber_image ) { if ( is_numeric( $timber_image ) ) { From 20e4e1cd5df79b9ab4449cbd35850a203f65f462 Mon Sep 17 00:00:00 2001 From: Lukas Gaechter Date: Wed, 17 Aug 2016 14:05:52 +0200 Subject: [PATCH 2/4] Add check for SVG and GIF image when requesting responsive src --- functions-images.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions-images.php b/functions-images.php index 4e73794..360358d 100644 --- a/functions-images.php +++ b/functions-images.php @@ -126,6 +126,11 @@ function get_timber_image_responsive( $timber_image, $size ) { function get_timber_image_responsive_src( $timber_image, $size ) { $timber_image = Timmy::get_timber_image( $timber_image ); + // Directly return source when we have an SVG or GIF image. + if ( in_array( $timber_image->post_mime_type, [ 'image/svg+xml', 'image/gif' ], true ) ) { + return ' src="' . $timber_image->src . '"'; + } + if ( ! $timber_image ) { return false; } From 48261e80681dc7bd86cd4a01624d32bbd9969d25 Mon Sep 17 00:00:00 2001 From: Lukas Gaechter Date: Tue, 11 Oct 2016 08:57:21 +0200 Subject: [PATCH 3/4] Update Readme, Changelog and composer.json --- CHANGELOG.md | 4 ++++ README.md | 2 +- composer.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 489ca1d..6afec7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.10.2 - 2016-10-11 + +- Optimized function `get_timber_image_responsive_src()` to directly return the image source when the image is an SVG or a GIF. + ## 0.10.1 - 2016-05-25 - Added composer.json to make it possible to load Timmy through Composer. diff --git a/README.md b/README.md index 9c141cf..ccff727 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ Returns the src for a TimberImage. `get_timber_image_responsive(int $post_id|TimberImage $timber_image, string $size)` -Returns the srcset, size, alt and title attributes for a TimberImage. +Returns the srcset, size, alt and title attributes for a TimberImage. If this function is used with an SVG or GIF image, the single src will be returned instead of srcset. ##### Usage in WordPress Templates diff --git a/composer.json b/composer.json index b1ef0ee..3ce40fa 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "mindkomm/timmy", - "description": "Opt-in plugin for Timber Library to make it even more convenient to work with images.", + "description": "Opt-in plugin for Timber Library to make it more convenient to work with images.", "license": "MIT", "require": { "php": ">=5.3.0", From acd5cfd08fdd9fca9d7ed99dd37926cae1ba6412 Mon Sep 17 00:00:00 2001 From: Lukas Gaechter Date: Tue, 11 Oct 2016 09:00:48 +0200 Subject: [PATCH 4/4] Update description --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3ce40fa..9e81cb7 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "mindkomm/timmy", - "description": "Opt-in plugin for Timber Library to make it more convenient to work with images.", + "description": "Advanced image manipulation for Timber.", "license": "MIT", "require": { "php": ">=5.3.0",