-
Notifications
You must be signed in to change notification settings - Fork 384
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. Would you please merge the latest changes in from (Update: I just merged the updates.)develop
since another PR (#793) also just modified this file.
With the file then updated, you please add a unit test to verify the fix.
It seems the changes in this PR now create a unit test failure:
|
Breaking change upon develop merge.
$normalized_urls[] = $normalized_url; | ||
} else { | ||
// This is not a URL we can extract dimensions from, so default to false. | ||
$url_map[ $original_url ] = $original_url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line being removed? It was recently added in #793.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the old version the line is unnecessary. The code after this line never uses url_map to get an url that cannot be normalized. Therefore, this line is unnecessary and can be removed.
In my version, it is also unnecessary and causes an error.
What happened:
In this case are two dimensionless images in one post with the same URI. One image of them includes additional the Host. The image with the URL is returned by the extractor with dimensions. Comparing to the other image - the image using the URI is returning without dimension.
The Post:
The Content:
The height is missing in the second image.
What you expected to happen:
What's happening:
The Extractor normalizes the URLs and stores the original url under its normalized urls. As a result, one of the original url is lost. The reason for this is that the normalized url should point to two original url. That's not possible.
Finally, the extractor iterates over the extracted dimensions. The extracted dimensions are just a subset of the original url. Only one original url is used.
Some possible resolutions:
The extractor stores the original urls as keys. The normalized url are stored as a value. That means we have no losses.
In the end the extractor iterates over the original urls. For each original url he gets the normalized url and asks for its dimension. This dimension is saved for the original urls.
Anything else we need to know?:
AMP: 1.0-beta1
Wordpress: 4.9.7
Container: Wordpress:latest
Theme: Twenty Seventeen 1.6
OS: MacOS 10.13.5