Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Switch image and audio block to embed block if URL is embeddable #11472
The PR #11410 implements a switch to an embed block, if the user adds an embeddable URL to the video block.
How has this been tested?
Add instagram URL to the Image block --> Instagram embed block
Audio seems to work fine, but I think we need a bit more work on the Image block here.
The problem is with sites like Imgur where you can link directly to the image, and the image URLs are also handled by oEmbed.
If you try to insert
https://i.imgur.com/AWJ2njK.jpg with an image block, the Imgur embed block will pick that up. However, you get Imgur's branding around the image, because now it's an embed. And you also don't have the resizing functionality of the Image block.
My suggestion would be that if the Image block does not recognise the URL as an image, it passes it on to the Embed code.
Seems to work nicely! I'd like to get some more feedback on this though, as I'm not sure if we should be so keen to bounce the user to an embed block. Perhaps if we recognise the URL as an image, e.g. the resource ends in jpg, png, etc. then we keep the user in the image block even if the image doesn't load, so that they can edit the URL if they'd made an error.
So that's mostly right :) What happens is that if we get an image error, we see if the URL has an embed handler. That embed handler might fail to embed the URL if it matches the handler's URL pattern, but is actually not a valid resource.
HOWEVER - the only providers that potentially hit this problem are Imgur and Photobucket, and they both return a placeholder image if you try to load an invalid image, so the error handling doesn't get triggered and the problem state doesn't happen.
I think we can rely on that good behaviour for this edge case.
Thanks for this!