WordPress.org

Ready to get started?Download WordPress

Forums

[Gallery] Full image size without using shortcode? (4 posts)

  1. fernandolawl
    Member
    Posted 1 year ago #

    Hi All,

    I was wondering if there was a way to set my gallery image size="full" without using the short code?

    I've already checked under settings -> media -> Image sizes... This was not the solution.

    I noticed that Add Media -> Insert image -> ATTACHMENT DISPLAY SETTINGS -> Size -> Full Size (drop down)... I'm looking for this same feature for the gallery images.

    Also, I would prefer not to use a plugin. Maybe some lines of code I need to function.php in my theme?

    Thanks in advance!

  2. fernandolawl
    Member
    Posted 1 year ago #

    I got the answer to this from:
    http://wordpress.org/support/topic/theme-function-set-default-image-size-for-gallery-shortcode-feature?replies=6

    I basically changed 'thumbnail' to 'full' in the media.php file:

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

  3. esmi
    Forum Moderator
    Posted 1 year ago #

    No! Never, ever, edit WordPress core scripts. And do not encourage others to do so. Editing core scripts can bring down your entire site and/or open security holes for hackers to use.

  4. ricoh
    Member
    Posted 1 year ago #

    esmi is right, if you read to the bottom of that post you referenced it shows you how to handle that modification. In your theme's function.php add the code

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

    Then create your custom function "my_gallery_shortcode" (or whatever you name it), copy the original code from the gallery_shortcode function in media.php and paste it into your custom function and then feel free to edit away until you get what you want. So your functions.php would look something like this.([...] means abbreviated, there is a bit of code in that funcion lol)

    function my_gallery_shortcode($attr) {
    [...]
    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));
    
    [...]
    }
    
    remove_shortcode('gallery', 'gallery_shortcode');
    add_shortcode('gallery', 'my_gallery_shortcode');

Topic Closed

This topic has been closed to new replies.

About this Topic