Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extractor that forgot duplicate images #1314

Merged
merged 5 commits into from
Aug 11, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions includes/utils/class-amp-image-dimension-extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static public function extract( $urls ) {
foreach ( $urls as $original_url ) {
$normalized_url = self::normalize_url( $original_url );
if ( false !== $normalized_url ) {
$url_map[ $normalized_url ] = $original_url;
$url_map[ $original_url ] = $normalized_url;
$normalized_urls[] = $normalized_url;
} else {
// This is not a URL we can extract dimensions from, so default to false.
Expand All @@ -30,9 +30,8 @@ static public function extract( $urls ) {
$extracted_dimensions = apply_filters( 'amp_extract_image_dimensions_batch', $extracted_dimensions );

// We need to return a map with the original (un-normalized URL) as we that to match nodes that need dimensions.
foreach ( $extracted_dimensions as $normalized_url => $dimension ) {
$original_url = $url_map[ $normalized_url ];
$return_dimensions[ $original_url ] = $dimension;
foreach ( $url_map as $original_url => $normalized_url ) {
$return_dimensions[ $original_url ] = $extracted_dimensions[ $normalized_url ];
}

return $return_dimensions;
Expand Down