Skip to content

Commit

Permalink
Merge pull request #27 from justcoded/develop
Browse files Browse the repository at this point in the history
Fix dummy images with existing sizes, but missing files
  • Loading branch information
aprokopenko authored Jul 3, 2018
2 parents 183f6cb + bec397e commit a8f8ceb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions just-responsive-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.1
Version: 1.6.2
Author: JustCoded / Alex Prokopenko
Author URI: http://justcoded.com/
License: GPL3
Expand Down Expand Up @@ -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.610';
self::$version = '1.620';

// init features, which this plugin is created for.
new components\Maintenance();
Expand Down
7 changes: 5 additions & 2 deletions models/RwdImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function get_set_sources() {
$option->size->h,
$option->size->crop
);
if ( JRI_DUMMY_IMAGE && empty( $meta_data['sizes'][ $option->key ]['file'] ) ) {
if ( JRI_DUMMY_IMAGE && empty( $meta_data['sizes'][ $option->key ]['valid'] ) ) {
$dummy_sizes[ $option->key ] = $this->dummy_source( $option, false, $attachment->ID, $meta_data );
}

Expand All @@ -489,7 +489,7 @@ public function get_set_sources() {
$option->size->crop
);

if ( JRI_DUMMY_IMAGE && empty( $meta_data['sizes'][ $retina_image_size ]['file'] ) ) {
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 );
}
}
Expand Down Expand Up @@ -585,12 +585,15 @@ public function resize_image( $attach_id, $meta_data, $key, $width, $height, $cr
$upload_dir = wp_get_upload_dir();
$image_baseurl = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . image_get_intermediate_size( $attach_id, $key )['path'];

$meta_data['sizes'][ $key ]['valid'] = true;

if ( ! file_exists( $image_baseurl ) || ! isset( $meta_data['sizes'][ $key ]['rwd_width'] )
|| $meta_data['sizes'][ $key ]['rwd_width'] !== $width || $meta_data['sizes'][ $key ]['rwd_height'] !== $height
|| ( 0 !== strcmp( $crop_str, $meta_data['sizes'][ $key ]['crop'] ) )
) {
// in dummy mode we do not resize anything.
if ( JRI_DUMMY_IMAGE ) {
$meta_data['sizes'][ $key ]['valid'] = false;
return $meta_data;
}

Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ 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.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 =
* Added attachment ID text to dev mode dummy images.
= Version 1.6.0 - 27 June 2018 =
Expand Down

0 comments on commit a8f8ceb

Please sign in to comment.