Skip to content

Commit fd1274f

Browse files
committed
use image_downsize filter as correct short-circuit method
1 parent 9c13747 commit fd1274f

File tree

1 file changed

+10
-3
lines changed
  • cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php

1 file changed

+10
-3
lines changed

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,17 @@ public function filter_downsize( $image, $attachment_id, $size ) {
722722

723723
if ( false !== $cloudinary_id ) {
724724
$this->in_downsize = true;
725-
$image = image_downsize( $attachment_id, $size );
725+
$intermediate = image_get_intermediate_size( $attachment_id, $size );
726+
if ( is_array( $intermediate ) ) {
727+
// Found an intermediate size.
728+
$image = array(
729+
$this->convert_url( $intermediate['url'], $attachment_id, array(), false ),
730+
$intermediate['width'],
731+
$intermediate['height'],
732+
true,
733+
);
734+
}
726735
$this->in_downsize = false;
727-
728-
$image[0] = $this->convert_url( $image[0], $attachment_id );
729736
}
730737

731738
return $image;

0 commit comments

Comments
 (0)