[wp-hackers] specific file name for uploaded images - -small.jpg instead of 300x300.jpg

Marko Heijnen mailing at markoheijnen.nl
Wed Apr 23 15:05:23 UTC 2014


Hey,

The best solution would be extending WP_Image_Editor and creating your own.
What you then do is changing the method multi_resize(). You could then pass a better filename to the method _save().
This could then include the variable $size what is the name of the image size.

Best,

Marko


On 18 Apr 2014, at 19:07, Cristovao Verstraeten <cristovao at apleasantview.com> wrote:

> Hi
> 
> If your question is about changing the size affix for images filenames
> I've been wondering about this for some time too and have these links to
> share:
> 
> http://bhoover.com/wp_image_editor-wordpress-image-editing-tutorial/
> http://wordpress.stackexchange.com/questions/123240/rename-image-uploads-replacing-width-and-height-in-filename-with-medium
> http://wordpress.stackexchange.com/questions/82193/rename-image-uploads-with-width-in-filename
> 
> Haven't got round to work on it so interested to know how you get along.
> 
> Greets,
> 
> -Cris.
> 
> 
> 
> 2014-04-18 13:57 GMT+02:00 BenderisGreat <greglancaster71 at gmail.com>:
> 
>> I havent tested this, but it appears you can specify a filename yourself
>> using get_output_format().  Looks to be one of the accepted methods for
>> wp_get_image_editor().
>> 
>> So maybe something like :
>> 
>> function adams_image_mod( $path, $args ) {
>> 
>>    $upload_to = wp_upload_dir();
>> 
>>    $img = wp_get_image_editor( $path );
>>        if ( !is_wp_error( $img ) ) {
>>            $rename = $img->get_output_format( 'some-new-name' );
>>            $saved = $img->save();
>> 
>>            if($saved) {
>> 
>>                wp_update_attachment_metadata( $id, $data );
>>            }
>>        }
>>    }
>> 
>>    return $img;
>> 
>> }
>> 
>> 
>> I didn't test this, its just an example - but Id imagine that is what the
>> wp
>> devs put that in for.  (make_image() and save() also accept filename args.
>> )
>> 
>> 
>> 
>> --
>> View this message in context:
>> http://wordpress-hackers.1065353.n5.nabble.com/specific-file-name-for-uploaded-images-small-jpg-instead-of-300x300-jpg-tp43880p43886.html
>> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> 
> 
> 
> 
> -- 
> Cristovao Verstraeten
> Jacob Van Lennepstraat 71
> 1053 HE Amsterdam
> +31646549095 - http://apleasantview.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list