Skip to content
Permalink
Browse files

perf: improve srcset replacement, use attachement id when present

  • Loading branch information...
selul committed Jan 10, 2019
1 parent 3ce600a commit 55872213e8bde8c323bf53678bc3fb293fd40b16
Showing with 4 additions and 2 deletions.
  1. +4 −2 inc/tag_replacer.php
@@ -143,6 +143,7 @@ public function filter_srcset_attr( $sources = array(), $size_array = array(), $
return $sources;
}
var_dump( $sources );
foreach ( $sources as $i => $source ) {
$url = $source['url'];
list( $width, $height ) = $this->parse_dimensions_from_filename( $url );
@@ -155,9 +156,10 @@ public function filter_srcset_attr( $sources = array(), $size_array = array(), $
$height = $image_meta['height'];
}
$url = $this->strip_image_size_from_url( $source['url'] );
if ( ! empty( $attachment_id ) ) {
$url = wp_get_attachment_url( $attachment_id );
} else {
$url = $this->strip_image_size_from_url( $source['url'] );
}
$args = array();
@@ -257,7 +259,7 @@ public function filter_image_downsize( $image, $attachment_id, $size ) {
$new_url,
$sizes['width'],
$sizes['height'],
false,
true,
);
}

0 comments on commit 5587221

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