In WordPress 2.5 and up, there's a built in Gallery feature that allows the option to add an image gallery to a Post or Page on your WordPress blog. (Ref: http://codex.wordpress.org/Gallery_Shortcode)
You can use a size
option to specify the thumbnail size you would like displayed. Valid values include "thumbnail", "medium", "large" and "full". The default is "thumbnail". The size of the images for "thumbnail", "medium" and "large" can be configured in WordPress admin panel.
ie. [gallery size="medium"]
My Question: I'm trying to hack up the [gallery] shortcode to allow for custom sizes at the time of input -- not trying to do this through the admin panel. I'd like to use something like, [gallery size="145x160"]
.
Rather then download a bloated plugin, I'd rather work with what's already there and I'm not sure where I need to go in my file structure to make the changes. I'm familiar with PHP but I'm afraid I'll make a change and then when I update future versions of WP, it will overwrite what I've set in motion.
Could someone help me out with this?
Thank you very much!
I know this is late, but I found this question trying to accomplish the same thing.
The Gallery does not have any built-in filters to allow this, so I developed a solution that works below.
In your theme's functions.php file, add the following lines of code:
remove_shortcode('gallery');
add_shortcode('gallery', 'custom_size_gallery');
function custom_size_gallery($attr) {
// Change size here - medium, large, full
$attr['size'] = 'medium';
return gallery_shortcode($attr);
}
This will interrupt the normal gallery call, revise the size being used, and then call the built-in WordPress gallery.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With