WordPress.org

Ready to get started?Download WordPress

Forums

Theme Function - set default image size for Gallery shortcode feature (6 posts)

  1. LayerCake
    Member
    Posted 3 years ago #

    /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!

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    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?

  3. LayerCake
    Member
    Posted 3 years ago #

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

  4. cleberkr
    Member
    Posted 3 years ago #

    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));

  5. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    On media.php on line 777... change...

    NEVER CHANGE CORE WORDPRESS FILES!

  6. itsjohn
    Member
    Posted 2 years ago #

    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

    }

Topic Closed

This topic has been closed to new replies.

About this Topic