[wp-hackers] wp-hackers Digest, Vol 111, Issue 12
Adam LaBarge
hi_word at hotmail.com
Tue Apr 22 03:55:09 UTC 2014
Hi Cris -
Thanks for those links.
ialocin's code in the second link: http://wordpress.stackexchange.com/questions/123240/rename-image-uploads-replacing-width-and-height-in-filename-with-medium worked out.
I added a default case with just img_size['width'] to catch any possible custom image sizes that don't need a small/medium/large name replacement.
I also rearranged the file naming to filename-wordSizeInsteadofImageSize.extention.
This code seems to add and delete the created files correctly.
I'm going to work on modifying it some so the small/medium/large images are put in their own directors under the standard year/month of the uploads folder.
Thanks all for the help. Solved as of now.
> From: wp-hackers-request at lists.automattic.com
> Subject: wp-hackers Digest, Vol 111, Issue 12
> To: wp-hackers at lists.automattic.com
> Date: Sat, 19 Apr 2014 12:00:01 +0000
>
> Send wp-hackers mailing list submissions to
> wp-hackers at lists.automattic.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> or, via email, send a message with subject or body 'help' to
> wp-hackers-request at lists.automattic.com
>
> You can reach the person managing the list at
> wp-hackers-owner at lists.automattic.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of wp-hackers digest..."
>
>
> Today's Topics:
>
> 1. Re: specific file name for uploaded images - -small.jpg
> instead of 300x300.jpg (Cristovao Verstraeten)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 18 Apr 2014 18:07:48 +0200
> From: Cristovao Verstraeten <cristovao at apleasantview.com>
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] specific file name for uploaded images -
> -small.jpg instead of 300x300.jpg
> Message-ID:
> <CAOESKLaeke52tw=04rG5oO3rqg1TYWv3UEXESM3EnoiihXdgLA at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> 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
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>
> ------------------------------
>
> End of wp-hackers Digest, Vol 111, Issue 12
> *******************************************
More information about the wp-hackers
mailing list