I want to remove the option to choose image resolution when creating the gallery with Gutenberg. Because when we select the gallery block and change it to large resolution, for example, not all images have this option and the gallery has different sizes (because you can assign different resolutions to each image), in my case I’m working with the height. If I remove this option I work with the css.
I already tried with theme.json, I didn’t succeed, I did another test with js and it didn’t work.
theme.json
"core/gallery": {
"spacing": {
"customMargin": false,
"customPadding": false
},
"elements": {
"image": {
"resizeMode": false
}
},
"settings": {
"sizes": false
}
}
functions.php
wp_enqueue_script('gallery-settings', get_template_directory_uri() . '/inc/js/custom-gallery-settings.js', array(), 8, true);
wp.hooks.addFilter(
'blocks.registerBlockType',
'custom/remove-gallery-image-sizes',
(settings, name) => {
if (name === 'core/gallery') {
// Remove o suporte de tamanhos de imagem
delete settings.attributes.imageSize;
}
return settings;
}
);
Lino Sousa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1