Skip to content

Commit

Permalink
fix: fix tag replacement on lazy load, preserve image size when found
Browse files Browse the repository at this point in the history
  • Loading branch information
selul committed Jan 21, 2019
1 parent 589b046 commit 5c6ef70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions inc/tag_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ public function process_image_tags( $content, $images = array() ) {
if ( false === $width && false === $height ) {
list( $width, $height ) = $this->parse_dimensions_from_filename( $tmp );
}
$optml_args = [ 'width' => $width, 'height' => $height ];
$optml_args = [ 'width' => $width, 'height' => $height, 'resize' => $resize ];
$tmp = $this->strip_image_size_from_url( $tmp );
$optml_args = array_merge( $optml_args, $resize );

$new_url = apply_filters( 'optml_content_url', $tmp, $optml_args );
$new_url = apply_filters( 'optml_content_url', $tmp, $optml_args );

if ( $new_url === $tmp ) {
continue; // @codeCoverageIgnore
Expand Down Expand Up @@ -133,6 +131,8 @@ private function parse_dimensions_from_tag( $tag, $image_sizes, $args = array()
if ( false === $args['width'] && false === $args['height'] && 'full' != $size && array_key_exists( $size, $image_sizes ) ) {
$args['width'] = (int) $image_sizes[ $size ]['width'];
$args['height'] = (int) $image_sizes[ $size ]['height'];
}
if ( 'full' != $size && array_key_exists( $size, $image_sizes ) ) {
$args['resize'] = $this->to_optml_crop( $image_sizes[ $size ]['crop'] );
}
}
Expand Down
3 changes: 1 addition & 2 deletions inc/url_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ public function build_image_url(
} elseif ( $args['height'] > 0 ) {
$args['height'] = $args['height'] > $this->max_height ? $this->max_height : $args['height'];
}

return ( new Optml_Image( $url, $args ) )->get_url( $this->is_allowed_site );
return ( new Optml_Image( $url, $args ) )->get_url( $this->settings->use_lazyload() ? false : $this->is_allowed_site );
}

/**
Expand Down

0 comments on commit 5c6ef70

Please sign in to comment.