I'd suggest that you only use one main folder for images anyway. This then obviates the need for conditional rename functions.
Use the public document root (html) as opposed to the virtual document root (php) when storing the data. This means that if you change server, the folders will still be valid.
e.g.
'image' datum could be "/images/coolstuff/mypicky.jpg" (absolute reference to public root)
If you change your folder structure (or think it could change), reconfiguring paths in a DB can be a real pain. One (and I mean just one) way of doing this is to have a config.php file as an include file in each of your pages. This file typically contains db connection data and other important variables and constants.
You could have this:
which then gives you the freedom to store images as: "coolstuff/mypicky.jpg"
Whenever an image path is taken from the DB, just prepend the $imageroot:
$img = $imageroot . $row['image'];
If you now decide that the image folder needs to be moved below another folder, e.g. to "/media/images/...", you just need to change the value in the config.php file and not worry about your DB values.