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

Cristovao Verstraeten cristovao at apleasantview.com
Fri Apr 18 16:07:48 UTC 2014


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


More information about the wp-hackers mailing list