Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Oct 11, 2016
2 parents f8e4edd + acd5cfd commit de704e6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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": "Advanced image manipulation for Timber.",
"license": "MIT",
"require": {
"php": ">=5.3.0",
Expand Down
5 changes: 5 additions & 0 deletions functions-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Timmy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down

0 comments on commit de704e6

Please sign in to comment.