To optimize SEO, I prefer to use descriptive, keyword-rich image filenames
instead of the auto-generated names used by web2py.
Currently, I am using a custom download function that looks up the
auto-generated filename in a database using the original filename as a key,
then uses the standard download function to retrieve it.
def images():
name = request.args(0)
row = dbs.image(filename=name)
if not row[file]:
raise HTTP(404)
else:
request.args.append(row[file])
return response.download(request,dbs)
This will retrieve an image using <img
src="/images/descriptive-filename.jpg"> instead of <img
src="/download/tablename.fieldname.bf4662d6c87d9b7f.636f726e65722d627261636b6574732e6a7067.jpg>
However, this takes 3 times longer on to retrieve an image on our server
(about 1200 ms vs 400 ms).
Is there another way that is relatively simple that 1) is fast, 2) wouldn't
break the default admin, and 3) automatically delete old images when an
image is updated in the admin?
--