1

I would like to add the size in the Gallery Settings in the Add Media.

I know to add the in the front-end by editing the media.php.

However, when I added the the lines in gallery.dev.js, they don't seem to work.

Here are the lines I had added in gallery.dev.js

Added size

 setup : function()
      var t = this, a, ed = t.editor, g, columns,size, link, order, orderby;

Added galsize in the same setup : function (approx line 128)

 if ( getUserSetting('galsize') ) t.I('size').value = getUserSetting('galsize');

Added in setup : function (approx line 141)

 size = a.match(/order='"['"]/i);

Added in setup : function (approx line 150 )

 if ( size && size[1] ) t.I('size').value = size[1];

Added size in update : function (approx line 170)

   all = all.replace(/\s*(order|link|columns|size|orderby)=['"]([^'"]+)['"]/gi, '');

Added in getsettings : function

    if ( I('size').value != 'medium' ) {
            s += ' size="'+I('size').value+'"';
            setUserSetting('galsize', I('size').value);
        }

2
  • 6
    You should never ever edit core files. There is almost certainly some hook you should be able to use to accomplish what you want (which, unfortunately, I'm not sure I'm understanding). Jan 15, 2012 at 18:13
  • thanks for the feedback. Basically in the Gallery Tab in Media Uploader, I would like to display the 4 media size part of the Gallery Settings
    – Jack
    Jan 16, 2012 at 4:55

1 Answer 1

5

first +1 for the first commenter . NEVER CHANGE CORE FILES.

this function will do the trick for your media upload :

function dl_custom_image_sizes_add_settings($sizes) {
       unset( $sizes['thumbnail']); //comment to remove size if needed
       //unset( $sizes['medium']);// uncomment to remove size if needed
       //unset( $sizes['large']);// uncomment to restore size if needed
       unset( $sizes['full'] ); // comment to remove size if needed
       $mynewimgsizes = array(
              "your-custom-size_name-1" => __( "Name_to_display1" ),
              "your-custom-size_name-2" => __( "Name_to_display2" ),
              "your-custom-size_name-3" => __( "Name_to_display3" )
       );
       $newimgsizes = array_merge($sizes, $mynewimgsizes);
       return $newimgsizes;
}
add_filter('image_size_names_choose', 'dl_custom_image_sizes_add_settings');

of course , this will work only if you define them first like so :

/*
Post Thumbnails Support
*/
add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts
add_image_size( 'your-custom-size_name-1', 220, 100, true ); // Permalink thumbnail size
add_image_size( 'your-custom-size_name-2', 50, 50, true ); // example home  thumbnail size
add_image_size( 'your-custom-size_name-3', 470, 350, false ); //  slider size

otherwise it will show greyed out buttons..

6
  • Hi should this be in the theme function.php? Would this add the image size only to the Gallery tab in the Media Uploader?
    – Jack
    Jan 16, 2012 at 4:52
  • yes.. put in functions.php
    – krembo99
    Jan 16, 2012 at 6:22
  • Hi, I added them into function.php, but I don't see any option in my Gallery Settings under Gallery tab
    – Jack
    Jan 16, 2012 at 13:50
  • they will show in the add media screen, like you initially asked .
    – krembo99
    Jan 16, 2012 at 14:02
  • hi krembo, thanks for the quick response. I want them to appear under the Gallery Settings, right above the Gallery Column.
    – Jack
    Jan 16, 2012 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.