Reader: if an image URL can't be made safe, discard it before the post card type is chosen #46144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Discussed in p5PDj3-4Up-p2.
Changes proposed in this Pull Request
As of #45503, Reader's image filtering discards any image that has a query string after we’ve taken off known Photon size parameters like
w
andquality
.However, we don't do this check until quite late in the rendering process, after we've chosen what type of card to display. If there are images that don't meet the standard, they remain in
post.images
and we end up with missing images displayed like this:This PR adds an earlier
safeImageUrl
check to the 'keep valid images' rule, so any URL that we can't make safe is removed frompost.images
andpost.content_images
before we choose a post card type.Testing instructions
Visit https://wordpress.com/read/feeds/98993195.
Without the PR, there'll be a bunch of empty images (all ads from a8.net with a query string):
With the PR applied, there'll be fewer gallery cards, but no missing images.
You can also run the unit tests with
yarn test-client client/lib/post-normalizer
.