Skip to content
Permalink
Browse files

fix: cropping behaviour when lazyload is off for certain edge causing…

… incorrect image resize
  • Loading branch information...
selul committed Feb 4, 2019
1 parent df4fb5c commit 8aca6dcbbdf1216b46dcfb575d06e26498e42ed1
Showing with 8 additions and 0 deletions.
  1. +8 −0 inc/tag_replacer.php
@@ -200,6 +200,11 @@ public function filter_srcset_attr( $sources = array(), $size_array = array(), $
return $sources;
}
$original_url = null;
$cropping = null;
if ( count( $size_array ) === 2 ) {
$sizes = self::size_to_crop();
$cropping = isset( $sizes[ $size_array[0] . $size_array[1] ] ) ? $this->to_optml_crop( $sizes[ $size_array[0] . $size_array[1] ] ) : null;
}
foreach ( $sources as $i => $source ) {
$url = $source['url'];
list( $width, $height ) = $this->parse_dimensions_from_filename( $url );
@@ -227,6 +232,9 @@ public function filter_srcset_attr( $sources = array(), $size_array = array(), $
$args['width'] = $source['value'];
}
}
if ( $cropping !== null ) {
$args['resize'] = $cropping;
}
$sources[ $i ]['url'] = apply_filters( 'optml_content_url', $original_url, $args );
}

0 comments on commit 8aca6dc

Please sign in to comment.
You can’t perform that action at this time.