Skip to content

Commit

Permalink
Make regex case insensitive and not considering matches in the middle…
Browse files Browse the repository at this point in the history
… of filenames and unify them
  • Loading branch information
leonidasmi committed Sep 13, 2024
1 parent 55aa767 commit 0763608
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/helpers/schema/image-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function generate_from_url( $schema_id, $url, $caption = '', $add_hash =
$attachment_id = $this->image->get_attachment_by_url( $url, $use_link_table );
if ( $attachment_id > 0 ) {
// First check if we should use the resized image and whether it is a resized image indeed.
if ( $check_for_resized && \preg_match( '/-\d+x\d+\.(jpg|jpeg|png|gif|webp)$/i', $url ) ) {
if ( $check_for_resized && \preg_match( '/-(\d+)x(\d+)\.(jpg|jpeg|png|gif|webp)$/', $url ) ) {
return $this->generate_from_resized_url( $schema_id, $attachment_id, $caption, $add_hash, $url );
}

Expand Down Expand Up @@ -91,7 +91,7 @@ public function generate_from_resized_url( $schema_id, $attachment_id, $caption
$data['url'] = $resized_url;
$data['contentUrl'] = $resized_url;

\preg_match( '/-(\d+)x(\d+)\.(jpg|jpeg|png|gif|webp)/', $resized_url, $matches );
\preg_match( '/-(\d+)x(\d+)\.(jpg|jpeg|png|gif|webp)$/', $resized_url, $matches );
$data['width'] = $matches[1];
$data['height'] = $matches[2];

Expand Down

0 comments on commit 0763608

Please sign in to comment.