✄codebook

a cut&paste code archive

Wordpress: Modify Default Image Name Suffix

05/12/09 11:41 AM

Credits

  1. exbionic for asking this question in the wordpress support forums
  2. fltseng and jstnryan for coming up with this hack!

Scenario

you want to change wordpress’s lame filenaming convention of images processed through their uploader into the media library.

basically you want your files, instead of being named:
IMAGE-150x150 and IMAGE-300x300 and IMAGE-1024x1024
you want it named:
IMAGE-thumb and IMAGE-medium and IMAGE-large

Solution

step1

in the directory where you store your wordpress core files, open .

step2

for wordpress 2.8 only… ??

go to line 358

for other versions: do a search for )

you should find this bit of code that looks like this:

step3

replace that chunk of code with:

tadaa!!!

do note that because this is a HACK, everytime you upgrade your wordpress version you have to redo this step. its unavoidable, until wordpress gets their act together and realizes how stupid this naming convention is, or until someone comes up with a plugin to fix this.

Tags: Hacks PHP


Comment