Mobile app version of vmapp.org
Login or Join
Pope3001725

: To track or not to track user created images for display in a dynamic website? I have a website that allows user to upload and display images. Currently, I am not using a database to track

@Pope3001725

Posted in: #ImageHosting

I have a website that allows user to upload and display images.

Currently, I am not using a database to track these user images. A folder having the user id as the folder name is created for each user and under each folder, the image files are labelled numerically with filenames ranging from 01.jpg to 20.jpg. Up to 20 such images can be displayed on each user page.

I am using javascript to hide these images in case of any of them is absent. I have seen many websites having user images with unique random filenames and possibly tracking these files with a database

Since obscurity is not something that I need for these web accessible images, is there any reason why I should track them with a DB?

I am not sure if a reduction of 404 errors is a good enough reason to justify the added complexity of maintaining a database or can anyone enlighten me?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Pope3001725

1 Comments

Sorted by latest first Latest Oldest Best

 

@LarsenBagley505

If your system works as it is now, I don't think it will be a good idea to move on. Since you will need lots of migration, script update, etc ..

From my point of view, the only reason you should store an image in DB (store only the path, not as binary) is to easily retrieve them. That's all. If you write your code depending on id as image filename, that's fine. On an other side, you're saving query from the DB. You don't have to query the DB to retrieve filename.

From a SEO point of view, it will be better if the image isn't only an id. Google (or what ever search engine) won't really know what 18.jpg is. It will have a better idea if you use an alt attribute, of course. But it will be better for him if you use slug instead and id (to retrieve them easily), like user-avatar-question-overflow-18.jpg. But this can also be done without a DB.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme