WordPress.org

Support

Support » Themes and Templates » Theme Function – set default image size for Gallery shortcode feature

Theme Function – set default image size for Gallery shortcode feature

  • /wp-includes/media.php line: 784 –

    extract(shortcode_atts(array(
    		'order'      => 'ASC',
    		'orderby'    => 'menu_order ID',
    		'id'         => $post->ID,
    		'itemtag'    => 'dl',
    		'icontag'    => 'dt',
    		'captiontag' => 'dd',
    		'columns'    => 3,
    		'size'       => 'thumbnail,
    		'include'    => '',
    		'exclude'    => ''
    	), $attr));

    [Please post code snippets between backticks or use the code button.]

    How do you setup up a function in your theme to override the default size ‘thumbnail’ – to size = full, or large.

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • I think you need to filter the post_gallery action hook.

    This is completely untested:

    function mytheme_gallery_shortcode_filter( $attr ) {
    	extract(shortcode_atts(array(
    		'order'      => 'ASC',
    		'orderby'    => 'menu_order ID',
    		'id'         => $post->ID,
    		'itemtag'    => 'dl',
    		'icontag'    => 'dt',
    		'captiontag' => 'dd',
    		'columns'    => 3,
    		'size'       => 'large'
    	), $attr));
    	return $attr;
    }
    add_filter( 'post_gallery', 'mytheme_gallery_shortcode_filter' );

    Give something like that a try?

    I think you’re on the right path – but it wasn’t successful. The site still defaults to thumbnails.

    I had the same problem and i’ve found the solution. On media.php on line 777… change default values of columns to 1 and of size to LARGE… it should look like this after done:

    extract(shortcode_atts(array(
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘menu_order ID’,
    ‘id’ => $post->ID,
    ‘itemtag’ => ‘dl’,
    ‘icontag’ => ‘dt’,
    ‘captiontag’ => ‘dd’,
    ‘columns’ => 1,
    ‘size’ => ‘large’,
    ‘include’ => ”,
    ‘exclude’ => ”
    ), $attr));

    On media.php on line 777… change…

    NEVER CHANGE CORE WORDPRESS FILES!

    this worked for me for the time being,

    remove_shortcode('gallery', 'gallery_shortcode');
    add_shortcode('gallery', 'my_gallery_shortcode');

    then

    function mjn_gallery_shortcode($attr) {

    copy everything from media.php within the gallery_shortcode function in here

    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Theme Function – set default image size for Gallery shortcode feature’ is closed to new replies.
Skip to toolbar