Skip to content
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

added support of insert from url option in cover block #41908

Draft
wants to merge 17 commits into
base: trunk
Choose a base branch
from

Conversation

akasunil
Copy link
Member

Currently it isn't possible to insert images or video via url for cover block.

What?

Fixes 10853

Testing Instructions

Please include step by step instructions on how to test this PR.

  1. Go to post edit.
  2. Insert a Cover Block.

Screenshots or screencast

CleanShot 2022-06-23 at 17 22 50@2x

CleanShot 2022-06-23 at 17 24 06@2x

@akasunil
Copy link
Member Author

@Mamaduka can you please review this PR.

@Mamaduka
Copy link
Member

Thanks for working on this, @sunil25393.

Unfortunately, using regex to detect media type won't work with URLs that don't have extensions attached. E.g. - https://avatars.githubusercontent.com/u/61308756?s=200&v=4.

@akasunil
Copy link
Member Author

Thanks for working on this, @sunil25393.

Unfortunately, using regex to detect media type won't work with URLs that don't have extensions attached. E.g. - https://avatars.githubusercontent.com/u/61308756?s=200&v=4.

Have addressed feedback. please review it again.

@akasunil
Copy link
Member Author

akasunil commented Jul 9, 2022

Any more feedbacks ?

@akasunil
Copy link
Member Author

@Mamaduka can we merge this PR if there isnt any more feedback.

Thank you.

@Mamaduka
Copy link
Member

Mamaduka commented Jul 25, 2022

Hi, @sunil25393

Sorry, I didn't get a chance to test or review changes here.

Quick notes:

@akasunil
Copy link
Member Author

Hi @Mamaduka

I have addressed feedback, and tested to make sure that isn't any CORS errors in the console.

@akasunil
Copy link
Member Author

Waiting for PR review.

@Mamaduka
Copy link
Member

I pinged some folks who recently worked on the Cover block for the reviews.

@draganescu
Copy link
Contributor

Hi @sunil25393,

Generally this works well if the host that we're linking to allows it. For instance I can easily run into:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://jsoncompare.org/LearningContainer/SampleFiles/Video/MP4/Sample-MP4-Video-File-Download.mp4. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

But this other host https://vod-progressive.akamaized.net/exp=1661274774~acl=%2Fvimeo-prod-skyfire-std-us%2F01%2F3603%2F14%2F368016235%2F1522131611.mp4~hmac=1558863b3bea9ef9660af2cfd3e6e8adce91ae3310367141d718837f2f1b198f/vimeo-prod-skyfire-std-us/01/3603/14/368016235/1522131611.mp4 works just fine.

This inconsistency has to be treated better, not sure how, but at this point as a user I have no idea why it does not work.

I have tested with URLs that allow remote linking and the features work as expected. We just need to figure out what to do if:

  • the media is being blocked by CORS
  • the media is not image or video, and we supply a link to a pdf - in the other cases we limit the "picker" to media files, but a user may paste any URL to any kind of file.

@akasunil
Copy link
Member Author

i see, do you know how we do for external image on image block ?

@draganescu
Copy link
Contributor

We don't do it there perfectly either. We can link to a pdf file and get an empty block.

Nevertheless in the image block we don't have to deal with CORS because the <img> tag used in the block's rendering is not subject to CORS policies, hence we don't do anything.

In the case of the cover block it is in your implementation of getContentTypeFromUrl where the CORS problem is triggered as we cannot read cross origin files by default. The CDN example allows it by default because its their policy but the other domain has the standard policy in place. Since we cannot detect the type because CORS prevents us, we would need a way to ask the user what they're linking to.

Added a needs design feedback for this.

@draganescu draganescu added the [Type] Enhancement A suggestion for improvement. label Aug 31, 2022
@draganescu draganescu added Needs Design Needs design efforts. Needs Technical Feedback Needs testing from a developer perspective. [Block] Cover Affects the Cover Block - used to display content laid over a background image labels Aug 31, 2022
@akasunil
Copy link
Member Author

Thank you @draganescu. as you said, we should add field for content type of link.

@draganescu draganescu added the Needs Design Feedback Needs general design feedback. label Sep 5, 2022
@richtabor
Copy link
Member

Added a needs design feedback for this.

Do we just need a better alert/fallback state when there's a failure?

@draganescu
Copy link
Contributor

@richtabor no, we also need to ask what kind of file are we linking to.

@akasunil
Copy link
Member Author

akasunil commented Mar 8, 2024

@draganescu need some design input for this, how we can implement content type field ?

Copy link

github-actions bot commented Mar 8, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @Wolf-DieterFiege.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: Wolf-DieterFiege.

Co-authored-by: sunil25393 <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: draganescu <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: Soean <[email protected]>
Co-authored-by: talldan <[email protected]>
Co-authored-by: bph <[email protected]>
Co-authored-by: joemaller <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@akasunil akasunil marked this pull request as draft April 19, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image Needs Design Feedback Needs general design feedback. Needs Design Needs design efforts. Needs Technical Feedback Needs testing from a developer perspective. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insert image using url for cover
4 participants