In wordpress image gallery, Using following code you can set the default image size for gallery in wordpress image gallery.

Select default image size for gallery in wordpress

In wordpress image gallery, it uses the full image size by default for every gallery but you can select or set the another image size. Using following code you can set the default image size for your wordpress image gallery.

Select default image size for gallery in wordpress

just copy and paste following code to your functions.php file:

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
 remove_shortcode('gallery');
 add_shortcode('gallery', 'custom_size_gallery');

 function custom_size_gallery($attr) {
      $attr['size'] = 'medium';
      return gallery_shortcode($attr);
 }
?>
default image size for gallery
default image size for gallery

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

2 thoughts on “Select default image size for gallery in wordpress”

  1. Hi Purab,

    Thank you for sharing this helpful code snippet. I’ve been wanting to be able to set my own size for the WordPress Gallery images for a while and your Block of code has been very helpful to me.

    I was wondering if you could write another post (or update this one) on how to use this block of code on a WordPress driven website, written in way that individuals without a lot of Techie type knowledge.

    Thanks heaps for this code snippet though. I’m going to work out how to implement this.

    Warmly,

    Ivan Bayross

Leave a Reply

Your email address will not be published.