I was wondering if any could help on my problem
I have this code from someone that runs fine except that the size does not function, default is always on “thumbnail”
function my_gallery_default_type_set_link( $settings ) {
$settings['galleryDefaults']['link'] = 'file';
$settings['galleryDefaults']['columns'] = '4';
$settings['galleryDefaults']['size'] = 'large';
return $settings;
}
add_filter( 'media_view_settings', 'my_gallery_default_type_set_link');
how can I make this always in large as a default?
This piece of code is actually working, the size of the gallery will be “large” by default if an other size is not manually selected. The real problem come from the dropdown itself that is not correctly set on initialisation, still in WP 4.8.2.
There is a ticket open with more details about this display error.
In the meantime, I found a workaround using the print_media_templates hook :
Step 1 – Define your gallery default image size
Step 2 – Debug the dropdown image size default value
Why are you using someone else’s custom code? There is already a Gallery shortcode with size option in it:
https://codex.wordpress.org/Gallery_Shortcode
Just call it with
[gallery size="thumbnail"]
.Actually, other code in other answers replaces default settings for existing galleries. Here’s the code to apply default settings only to the new gallery: