• Hello everybody,

    I’m trying to change the default settings of the WP gallery.
    I mean, the number of columns, and the link.
    I was looking for some filter, but I did’t find them.

    I see, as an example, that the default number of column is declared in the media-template.php, like this:

    <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, 3 ); ?>>

    so I think there’s no way to change it ( of course I don’t want to touch the core! ).

    I can go to filter the_content ( like show in zeo’s blog ). But I don’t like to add filter to the_content, because I think it uses a lot of resources on every page.

    So is there someone that know how to do that?

    thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • it would be nice to see wordpress at least add the option of chosing “0” columns from the drop down menu. that way it won’t break in fluid layouts.

    i’ve just used this to clear all the linebreaks from wordpress’s fascist column structure:

    <script>
    	jQuery('.gallery br').remove();
    </script>

    found the idea to use jquery to edit wp core in a future-version proof way from reading this.

    Moderator bcworkz

    (@bcworkz)

    The selection in the media template merely sets the ‘columns’ attribute in the shortcode that gets generated. The shortcode by default is processed by gallery_shortcode() defined in wp-includes/media.php. You can cause the gallery shortcode to be processed by your own function by hooking the filter ‘post-gallery’. Your function could choose to ignore the columns attribute and display the images any way you like. Naturally, your function can also generate whatever links you like as well.

    This is the “clean” way of taking over the gallery shortcode processing. If your function is based largely on the default code, you need to assume the responsibility of reviewing any updates to the default code and applying any pertinent modifications to your own function.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change the default settings of a gallery’ is closed to new replies.