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

Fix: Image Block: Add protocol to custom link #17227

Conversation

donmhico
Copy link
Contributor

Description

Append HTTP protocol to custom link set in Image Block.

How has this been tested?

  1. Create a post.
  2. Insert an Image Block and select image from library.
  3. In the Toolbar click "Insert Link" icon.
  4. Enter an address. (Tested addresses with http, https, as well as without e.g. google.com.)
  5. Click the "external link" icon besides the custom link. (It will redirect you to the custom URL instead of a relative URL).
  6. Save the post and view it in the frontend.
  7. Click the image. (It will now redirect you to the custom URL instead of a relative URL).

Worth consideration

The change uses prependHTTP which will always prepend HTTP. It might be worth considering prepending HTTPS instead.

Types of changes

Fixes #17155.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.

@talldan talldan added [Block] Image Affects the Image Block [Type] Enhancement A suggestion for improvement. [Type] Bug An existing feature does not function as intended and removed [Type] Enhancement A suggestion for improvement. labels Aug 29, 2019
@senadir
Copy link
Contributor

senadir commented Sep 15, 2019

this PR looks good expect I can't get it to work because this doesn't seem to be set to true linkDestination === LINK_DESTINATION_CUSTOM.

Also, wouldn't make sense to add //: instead of http:// to allow both normal and secure protocols to exist depending on the website. I would go as far as only allowing https protocols, but this is for another discussion.

@draganescu
Copy link
Contributor

This doesn't seem to work @donmhico Would you have some time to revise and test this PR?

@aduth aduth added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Jan 24, 2020
@donmhico donmhico requested a review from ajlende as a code owner October 1, 2020 09:40
Base automatically changed from master to trunk March 1, 2021 15:42
@annezazu
Copy link
Contributor

Closing this PR out due to lack of responses. Feel free to re-open and continue working on this though 🥳

@annezazu annezazu closed this Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom URLs in images without schema creates relative links
6 participants