Results 1 to 8 of 8

Thread: Tweaking the new media uploader "Scale to..." option

  1. #1
    mtwelve is offline Hello World
    Join Date
    Nov 2010
    Posts
    5

    Icon5 Tweaking the new media uploader "Scale to..." option

    Hello,


    Right... what I'm looking to do is utilize the new "Scale images to match the large size..." to resize images to a size I dictate that is not the default "Large" size.
    I've found where the new function is configured; lines 1340-1341 in \wp-admin\icludes\media.php

    Code:
    var resize_height = <?php echo get_option('large_size_h', 500); ?>,
    resize_width = <?php echo get_option('large_size_w', 500); ?>,
    Now I have a temporary fix; I've replaced the options it calls with some I've inserted myself... the thing is I'm editing the core files as I don't know if I can filter this...? (I presume I want to filter?) Can anyone with a stronger knowledge have a look...?


    The other thing is to make sure that the box always stays checked; or at least is checked by default. Its mentioned here as being not too tricky, any advice?



    The new uploader is fantastic and if I can just sort these two bits out then it saves using some rather temperamental code.


    Massive Thanks

  2. #2
    mtwelve is offline Hello World
    Join Date
    Nov 2010
    Posts
    5

    Default

    this
    Code:
    set_user_setting ('upload_resize', true);
    in funtions.php seems to automatically check the box

  3. #3
    mtwelve is offline Hello World
    Join Date
    Nov 2010
    Posts
    5

    Default

    So I was digging around on trac.wordpress.org to see if anyone else was discussing/suggesting solutions that would fix my issue. I found this but I don't think its quite relevant; is it?

    Made me think though that as there clearly isn't a filter or hook (could someone confirm which I'm searching for) to tap into then, I (we) would need to submit something and press for it to be included in the next release.

    I was thinking of something last night like this

    Code:
    function set_resize_on_upload_options() {   
    $resize_image_h = get_option('large_size_h', 750);
    $resize_image_w = get_option('large_size_w', 750);
    }
    
    
    <script type="text/javascript">
    var resize_height = <?php echo $resize_image_h; ?>,
    resize_width = <?php echo $resize_image_w; ?>,
    wpUploaderInit = <?php echo json_encode($plupload_init); ?>;
    </script>
    My patchy knowledge hints that as the variables are enclosed in a function you could just substitute that function in your own functions.php or maybe it needs a hook within the function.

    Even if Im way off any nudges in the right direction would be great so I can start a campaign to get this noticed.


    Many Thanks!

  4. #4
    mmuro is offline Hello World
    Join Date
    Mar 2011
    Location
    Birmingham, AL
    Posts
    13

    Default

    Huh?

    You are trying to make a custom image size? There's a function for that: http://codex.wordpress.org/Function_...add_image_size

  5. #5
    mtwelve is offline Hello World
    Join Date
    Nov 2010
    Posts
    5

    Default

    no no no...

    The next version of WordPress has a check box on the 'New Media' lightbox that will resize the 'Full Size' image to match the 'Large Size' set in Media Settings; thus removing the original 'Full Size' image and leaving you it resized.

    new-media-uploader.jpg

    The current setup (lines 1340-1341 in \wp-admin\icludes\media.php) uses the settings that you set for the Large image size in Media Settings. It uses large_size_h and large_size_w and then falls back to the other value 500.

    I want to be able to modify which options it calls and/or manually set the size without modifying the core files.

    Looking through the media.php file I cant see how that is possible but Im not well versed on filters/actions but I'm very keen to make a song and dance about it as this would put the icing on the cake of the new uploader.

    Cheers

  6. #6
    andreasnrb's Avatar
    andreasnrb is offline Kegger
    Join Date
    Jun 2009
    Posts
    595

    Default

    You can return a different value by hooking into the option filter.

    apply_filters( 'pre_option_' . $option, false );

  7. #7
    mtwelve is offline Hello World
    Join Date
    Nov 2010
    Posts
    5

    Default

    Sorry to be an absolute a*se but can you walk me through it

    ---

    Would this filter that size/option for the whole installation; as in would it make all large images the size specified by the filter or just within that function?

    Filters as far as I was aware needed for there to be an apply_filters in the line your looking to change...?


    Many Thanks!

  8. #8
    andreasnrb's Avatar
    andreasnrb is offline Kegger
    Join Date
    Jun 2009
    Posts
    595

    Default

    Well there is a filter
    so you would write
    PHP Code:
    if(media uploader loaded){//so not always change the large_scale values, but only when you want to.
      
    apply_filters('pre_option_large_size_h','prefix_set_new_full_scale_h',0);
      function 
    prefix_set_new_full_scale_h($h){
          return 
    250;
      }
      
    apply_filters('pre_option_large_size_w','prefix_set_new_full_scale_w',0);
      function 
    prefix_set_new_full_scale_w($w){
          return 
    500;
      }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •