Source file: modules/tiled-gallery/tiled-gallery.php
View in GitHubParameters
- $tiled_gallery_content_width
-
(string) Default Tiled Gallery content width.
Changelog
Since: Jetpack 2.1.0
Notes
You can use this filter to define a custom Content Width value, that will only apply to Jetpack Tiled Galleries:
function jeherve_custom_tiled_gallery_width() { return '800'; } add_filter( 'tiled_gallery_content_width', 'jeherve_custom_tiled_gallery_width' );
Hi,
Where exactly should I place this code?
You can follow the instructions here to find out where to use code snippets that use hooks to customize a plugin or a theme.
Thanks Jeremy
Can’t I just add the snippet to my child theme’s functions.php? It didn’t work.
Yes, you can add such snippet to your theme’s functions.php file, or in a functionality plugin as explained here.
Please, tell me, how can I remove padding between pictures in tiled gallery?
You can use some CSS like this to set the padding to zero:
.tiled-gallery .tiled-gallery-item {
box-sizing: border-box;
padding: 0;
}
Having said that, tiled galleries adjust the image size dynamically in a very complex process, so removing the padding might make some of the images look or act strangely. Getting it to work perfectly may not be possible.
Hi there
I also like to change the width of Jetpack gallery and tried adding this to code snippet but it didn’t work:
function jeherve_custom_tiled_gallery_width() {
return ‘800’;
}
add_filter( ’tiled_gallery_content_width’, ‘jeherve_custom_tiled_gallery_width’ );
Has there been an update to the code?
Hi there!
Can you reach out to us here for support please?
https://jetpack.com/contact-support/
Thanks!
Instead of a fixed width is it possible for it to fit its container?
No, that is not an option. The filter relies on WordPress’
$content_width
, that only accepts a fixed value. You can read more about it here.Hello, I’m looking to inject an additional title just before the tiled gallery output. A hijack the [gallery] shortcode affects the tiled display. Can you suggest me how to deal with it? Thank you.
The
tiled_gallery_content_width
filter won’t be too helpful here. You would need to add your own content to all galleries using WordPress’ ownpost_gallery
filter:https://developer.wordpress.org/reference/hooks/post_gallery/
If you need help using this filter, you can post in the WordPress.org support forums for help.