Adam LaBarge
2014-04-22 03:55:09 UTC
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.
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.
Subject: wp-hackers Digest, Vol 111, Issue 12
Date: Sat, 19 Apr 2014 12:00:01 +0000
Send wp-hackers mailing list submissions to
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
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of wp-hackers digest..."
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
Subject: Re: [wp-hackers] specific file name for uploaded images -
-small.jpg instead of 300x300.jpg
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
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.
Cristovao Verstraeten
Jacob Van Lennepstraat 71
1053 HE Amsterdam
+31646549095 - http://apleasantview.com
------------------------------
Subject: Digest Footer
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
------------------------------
End of wp-hackers Digest, Vol 111, Issue 12
*******************************************
Date: Sat, 19 Apr 2014 12:00:01 +0000
Send wp-hackers mailing list submissions to
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
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of wp-hackers digest..."
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
Subject: Re: [wp-hackers] specific file name for uploaded images -
-small.jpg instead of 300x300.jpg
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
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.
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().
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.
)
--
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
http://lists.automattic.com/mailman/listinfo/wp-hackers
--using get_output_format(). Looks to be one of the accepted methods for
wp_get_image_editor().
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.
)
--
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
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
http://lists.automattic.com/mailman/listinfo/wp-hackers
------------------------------
End of wp-hackers Digest, Vol 111, Issue 12
*******************************************