Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
5  
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). –  helenhousandi Jan 15 '12 at 18:13
    
+1 for the "not touch core files" –  krembo99 Jan 16 '12 at 2:38
    
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 '12 at 4:55

2 Answers 2

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..

share|improve this answer
    
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 '12 at 4:52
    
yes.. put in functions.php –  krembo99 Jan 16 '12 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 '12 at 13:50
    
they will show in the add media screen, like you initially asked . –  krembo99 Jan 16 '12 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 '12 at 14:07
// Example image size added:
add_image_size( 'just_testing', 100, 100, true );

// Add your example image size to the selection:
add_filter( 'image_size_names_choose', 'wpse_39004_image_size_names_choose' );
function wpse_39004_image_size_names_choose( $image_sizes ) {
    $image_sizes['just_testing'] = __( 'Just Testing', 'textdomain' );
    return $image_sizes;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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