Skip to content

Commit 8a4d8e4

Browse files
committed
only add srcset on front
1 parent b038652 commit 8a4d8e4

File tree

1 file changed

+8
-5
lines changed
  • cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,14 @@ public function filter_out_local( $content ) {
364364
$new_tag = str_replace( $poster, $cloudinary_url, $new_tag );
365365
}
366366
}
367-
$image_meta = wp_get_attachment_metadata( $attachment_id );
368-
$image_meta['file'] = pathinfo( $cloudinary_id, PATHINFO_FILENAME ) . '/' . pathinfo( $cloudinary_id, PATHINFO_BASENAME );
369-
$image_meta['overwrite_transformations'] = $overwrite_transformations;
370-
$new_tag = wp_image_add_srcset_and_sizes( $new_tag, $image_meta, $attachment_id );
371-
$content = str_replace( $asset, $new_tag, $content );
367+
// Add srcset on front end.
368+
if ( ! is_admin() ) {
369+
$image_meta = wp_get_attachment_metadata( $attachment_id );
370+
$image_meta['file'] = pathinfo( $cloudinary_id, PATHINFO_FILENAME ) . '/' . pathinfo( $cloudinary_id, PATHINFO_BASENAME );
371+
$image_meta['overwrite_transformations'] = $overwrite_transformations;
372+
$new_tag = wp_image_add_srcset_and_sizes( $new_tag, $image_meta, $attachment_id );
373+
}
374+
$content = str_replace( $asset, $new_tag, $content );
372375
}
373376

374377
return $this->filter_video_shortcodes( $content );

0 commit comments

Comments
 (0)