WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.18k forks source link

Images: Overriding "Link To" #15865

Closed desrosj closed 4 years ago

desrosj commented 5 years ago

I couldn't find an issue or discussion for this. Feel free to redirect this discussion to a different area.

Describe the bug In the Classic Editor, the default value for the "Link To" field for images could be overridden using the image_default_link_type filter. For galleries, the media_view_settings filter could be used to change the default Link To value.

In the block editor, it is not clear to me how to override these defaults, if you can at all. I also thought investigating if these preexisting filters could be used so that any preference that was defined for the Classic Editor would automatically be respected in the block editor.

This came up investigating Trac-46052. From my comment on that issue:

The image_default_link_type option is used to control the preferred image Link To value. This can be set to three values: none (default for new installs since WordPress 2.7 [https://core.trac.wordpress.org/browser/tags/5.2.1/src/wp-admin/includes/schema.php#L502 according to the database schema]), file, or post.

For galleries, the proper way to override the default Link To value is using the media_view_settings filter to add galleryDefaults to the list of settings ([https://core.trac.wordpress.org/browser/tags/5.2.1/src/wp-includes/media.php#L3768 filter documentation]).

These are the results of my testing:

  • While using the block editor with the image block, the option ''is not'' respected in the Link To field.
  • When using the block editor with the Classic Editor block to insert an image, the option ''is'' respected in the Link To field.
  • While using the block editor with the gallery block, the default Link To value ''is not'' respected.
  • When using the block editor with the Classic Editor block to insert a gallery, the default value ''is'' respected.
  • When using the Classic Editor plugin, both plugins and images correctly respect the methods above.

There is also a similar issue for image sizes to make the editor remember preference on a per user basis (#8663). This could also be explored for Link To, I think.

ghost commented 5 years ago

+1 I'm also looking for a way to make 'Link to media file' the default behaviour. I keep forgetting this after saving a post, even after a year using the new editor.

okainov commented 5 years ago

+1, also interested. See related https://wordpress.stackexchange.com/questions/327396/set-default-image-link-target-in-gutenberg-image-block and https://wordpress.org/support/topic/image_default_link_type-doesnt-work/

catdotgif commented 5 years ago

This might seem like a minor issue, but it has a large and negative impact on the quality of the experience of using Gutenberg for the user.

Gitami commented 4 years ago

Before Gutenberg (in the Classic editor), the default behavior was that it remembered the last setting you had used. So if you had a "link to" media file - it just did that automatically going forward, until you changed it to something else, whereafter it did that going forward. Simple. That was such as subtle yet awesome UI design choice. Unfortunately it just disappeared out the window when Gutenberg came along.

For at long time I honestly just thought: "well okay, its new, they'll get around to fixed / reimplemeting that feature". Yet here we are. over a year later and still nothing. So you've forced me to take matters into my own hands and write this response.

This missing little feature cost millions of users extra clicks single every day - and it has cost me personally thousands of clicks since i moved to WP5.

Could we get this issue prioritized! Thanks.

talldan commented 4 years ago

This seems like a duplicate of https://github.com/WordPress/gutenberg/issues/10173.

I'll keep this open as it seems like the discussion has evolved.

skorasaurus commented 4 years ago

I was wondering about this as well and I think the following PRs aim to solve this? https://github.com/WordPress/gutenberg/pull/13797 and https://github.com/WordPress/gutenberg/pull/17401 which appears to supersede the 13797.

noisysocks commented 4 years ago

Duplicate of https://github.com/WordPress/gutenberg/issues/10173.