Repository navigation
Build an img code for oEmbed photo responses - #584
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
oEmbed responses of
type: photohave nohtmlfield. The spec puts the image inurl, withwidthandheight. The genericCodedetector only readshtml, so for these providers$info->codeisnulleven though the image is right there.Live reproduction (GIPHY)
master(4.5.1):codeisnull.<img src="https://media0.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif" alt="Cat Working GIF - Find & Share on GIPHY" width="480" height="480" />, width 480, height 480.The same happens live with DeviantArt (
https://www.deviantart.com/sakimichan/art/Misty-510056679).What changes
src/Detectors/Code.php: when the oEmbed response has nohtml, and only then, a newdetectFromOEmbedPhoto()checks fortype: photowith aurl. It builds the tag withEmbed\html('img', ...)(src,altfromtitle,width,heightwhen present, all escaped) and returns anEmbedCodewith the width and height.htmlstill wins, so providers that send both are unchanged.html(for examplelink) still fall through to OpenGraph, Twitter and content type, as before.Fixtures
Three page fixtures change from
'code' => nullto an<img>code, because their cached oEmbed responses aretype: photo:tests/fixtures/www.deviantart.com.art-misty-510056679.phptests/fixtures/pachunka.deviantart.com.art-cope-145564099.phptests/fixtures/www.23hq.com.zzleeper-photo-16600737.phpThey were regenerated from the existing cache only (no network). No other fixture changes.
Tests
New
tests/OEmbedPhotoCodeTest.php, offline (fake HTTP client, no network):<img>with width and heighthtmlstill wins over the photourlhtmlstill has no codeResults:
Backward compatibility
No BC break. The only visible difference is that
codeis now filled for oEmbed photo responses where it used to benull.Replaces #581 (moved from my fork to this repository).