I’m building a simple CMS and have the login, edit pages etc.
Those of you who have built your own CMS, how do you store user uploaded images with an alt tag?
File name/path in the database and alt tag there too?
Then grab the id when writing out the image and create a php page that acts as an image?
eg:
<?php include image.php?id=1; ?>
image.php outputs:
get id
connect to db
echo '<img src="nameofimageandextension" alt="alttag">';
Or would that not be a good idea?
Where is the problem in creating a table ( or an extension to your user table ) something like this?
And access it like this:
I believe this is the cleanest and easiest ( best? ) way to do it.
And to answer to the 2nd question:
Depends on how you want to protect your images, but normally, no, it’s better to show the real image link. You don’t want users to see all images as
myimage.php?id=1style unless those are captcha or otherone time use onlyimages.Using PHP as image url messes up some browser cache, so this will mean that a user has to load your entire site every time (s)he wisits it.
Not pleasant for the user or your server traffic.