Open renatho opened 2 weeks ago
I suspect we'll need to do something like add a placeholder image if the iframe doesn't work. We'd need to work with design on that. We should avoid implementing any sort of complex solution for this at this point, especially given that we don't know how commonplace this scenario will be.
I looked into the issue and found a workaround that's not too hard to implement. Sites prevent loading them in iFrames by using headers. So we can just create a small proxy endpoint in between to call the site and rewrite/delete the header.
Here's a demo with a small proxy I created with Express locally in 5 minutes, you can see I've loaded https://automattic.com in an iFrame-
There are two main problems with this-
Because of the two problems mentioned above, especially the second one which makes me think we should avoid trying to load such sites with any workarounds, I think we'd be better off finding a design solution that avoids loading such a site in an iFrame.
As for the potential solution, I see two ways to go about it.
I prefer the second solution because we can avoid showing a failure message or a content-jumping after a few seconds (assuming the iFrame will take a couple of seconds trying to load the URL before failing).
WDYT? cc @donnapep @renatho
As discussed in the Tycoon Leads call, we can use the mshots
library to generate a screenshot and use that for all sites. This has the added bonus of the user not being able to click and navigate around inside of an iframe
.
Details
The site preview is already implemented as part of https://github.com/Automattic/wp-calypso/issues/91776, but I noticed that some sites might not allow being rendered inside an
iframe
. One example is https://automattic.com/.Was it already solved somewhere? Do we need a new solution? Would the
WebPreview
component help with that?Checklist
Related
https://github.com/Automattic/dotcom-forge/issues/7703