diff --git a/just-responsive-images.php b/just-responsive-images.php index f7d96a0..83ea418 100644 --- a/just-responsive-images.php +++ b/just-responsive-images.php @@ -4,7 +4,7 @@ Plugin Name: Just Responsive Images Description: Providing full control to set your own responsive image properties for WordPress 4.4+, the ability to use the <picture> tag, auto-generate image backgrounds and supports retina images. Tags: responsive post thumbnail, post thumbnail as background, retina support, retina image, retina post thumbnail, responsive post attachment, responsive images, responsive attachments, post thumbnails, media -Version: 1.6.2 +Version: 1.6.4 Author: JustCoded / Alex Prokopenko Author URI: http://justcoded.com/ License: GPL3 @@ -49,7 +49,7 @@ class JustResponsiveImages extends core\Singleton { protected function __construct() { // init plugin name and version. self::$plugin_name = __( 'Just Responsive Images', JustResponsiveImages::TEXTDOMAIN ); - self::$version = '1.620'; + self::$version = '1.640'; // init features, which this plugin is created for. new components\Maintenance(); diff --git a/models/RwdImage.php b/models/RwdImage.php index bf661c7..3e08181 100644 --- a/models/RwdImage.php +++ b/models/RwdImage.php @@ -298,7 +298,7 @@ public function background( $selector, $size ) { } // generation of responsive sizes. foreach ( $rwd_options as $subkey => $option ) { - if ( ! isset( $sources[ $subkey ] ) || is_null( $option->srcset ) ) { + if ( ! isset( $sources[ $subkey ] ) || is_null( $option->bg ) ) { continue; } $baseurl = $this->get_attachment_baseurl( $sources[ $subkey ]['attachment_id'] ); @@ -480,14 +480,19 @@ public function get_set_sources() { if ( $option->retina_options ) { foreach ( $option->retina_options as $retina_descriptor => $multiplier ) { $retina_image_size = ImageSize::get_retina_key( $option->key, $retina_descriptor ); - $meta_data = $this->resize_image( - $attachment->ID, - $meta_data, - $retina_image_size, - $option->size->w * $multiplier, - $option->size->h * $multiplier, - $option->size->crop - ); + // generate retina only if original size is bigger in all dimensions than retina size. + $retina_w = $option->size->w * $multiplier; + $retina_h = $option->size->h * $multiplier; + if ( $retina_w < $meta_data['width'] && $retina_h < $meta_data['height'] ) { + $meta_data = $this->resize_image( + $attachment->ID, + $meta_data, + $retina_image_size, + $retina_w, + $retina_h, + $option->size->crop + ); + } if ( JRI_DUMMY_IMAGE && empty( $meta_data['sizes'][ $retina_image_size ]['valid'] ) ) { $dummy_sizes[ $retina_image_size ] = $this->dummy_source( $option, $multiplier, $attachment->ID, $meta_data ); diff --git a/readme.txt b/readme.txt index c4100c7..c7f92ae 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Tags: responsive post thumbnail, post thumbnail as background, retina support, r Author: JustCoded / Alex Prokopenko Author URI: http://justcoded.com/ Requires at least: 4.5 -Tested up to: 5.0.1 +Tested up to: 5.0.3 Requires PHP: >=5.6 License: GPL3 Stable tag: trunk @@ -90,6 +90,10 @@ There are no any special upgrade instructions for version 1.0 - 1.3 To upgrade remove the old plugin folder. After than follow the installation steps 1-2. == Changelog == += Version 1.6.4 - 25 January 2018 = + * Fixed always resize for retina if 2x is bigger than original image. += Version 1.6.3 - 9 August 2018 = + * Fix background usage if no other options specified. = Version 1.6.2 - 3 July 2018 = * Fix dev mode dummy images with sizes set in DB but missing on file system. = Version 1.6.1 - 28 June 2018 =