-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
image_default_link_type is ignored by Gutenberg #10173
Comments
Please fix this annoying bug :( |
Finally, I found this working replacement! Put this code to the <?php
add_action( 'init', 'set_link_to_media_by_default' );
function set_link_to_media_by_default() {
$post_type_object = get_post_type_object( 'post' );
$post_type_object->template = array(
array( 'core/gallery', array(
'linkTo' => 'media',
) ),
);
} You can also specify another attributes too, for example columns: <?php
add_action( 'init', 'set_link_to_media_by_default' );
function set_link_to_media_by_default() {
$post_type_object = get_post_type_object( 'post' );
$post_type_object->template = array(
array( 'core/gallery', array(
'linkTo' => 'media',
'columns' => 4,
) ),
);
} |
Any reference what file this is changed in? |
For example |
I found that the 'Link To' default setting is write in the
After I change the default to 'media' , every image that I insert into the post , is 'Link To Media File' as default now. |
You have a working example three post above :) |
Apparently, this is a case of "your mileage may vary." When I added this code to functions.php, a gallery block was automatically added to new posts and there was no change to link to. |
NOTE there are two different suggestions for adding to functions.php via child theme... Did you use the one that adds the set link function: "function set_link_to_media_by_default" or the other one? |
I tried creating a new tiny child theme, to define the above "function set_link_to_media_by_default()", and after some confusion, was able to successfully activate my child theme, BUT new galleries still default to link "none". And I find that by using a child theme I lose all my many randomized header files, and have re-establish them as header files (from medial library) ONE at a TIME rather than by selecting multiple filles... lame! Deactivating this useless child theme does restore my headers, glad to say. |
Sorry for the confusion. The set link function was the one I tried. |
I think we should have an option for default Media Link on Gallery. The pictures are ridiculously little O_o ! |
Also reported on the forums. I was able to reproduce it. |
It's been a while since the last update. Is there a timeline when this going to be fixed? |
When I add this code to functions.php, it's like HmCody said. It's annoying to have to set the link for each image and gutenberg not using image_default_link_type |
This is still awaiting development. The block editor needs to respect the existing |
Any updates? This feature (or we shall call it basic functionality...) would be crucial in my project. @WordPress: This issue exists for a long time. Is that so difficult to fix such a small bug? |
The above solution by adding code to functions.php doesn't work for. Every other gallery block is still with none by default. |
any news? it's so annoying :( |
I tried the following, which seems to work. Like in this example, you can register a Gutenberg JavaScript file
Similar to this example, you can now change the default settings of blocks in
The possible settings of gallery blocks can be found here. |
The problem with this approche is that the settings.attributes.linkTo.default value will not store inside the block markup because it's the default. If you change the default value later or remove the filter, the block will break. |
Thanks for pointing that out. |
The setting image_default_link_type from options.php is not used by Gutenberg: mine is set to "file", yet the editor defaults every image or gallery to the "none" link type. I have to set them all manually instead.
The text was updated successfully, but these errors were encountered: