Forum Moderators: coopster
i.e. /?var=image-1 would show image 1
, /?var=image-2 would show image 2
etc etc.
Is this possible with php? I'm not expecting anybody to write me a script but if someone could help point me in the right direction that would be fantastic.
First, you can name all your files in the folder image-1.jpg, image-2.jpg and when the variable is passed in create a new variable called $imageFile = $_GET['var'] . ".jpg"; and then in your html have <img src="/images/<?php echo $imageFile ?>">. This will only really work if you have full control over the naming conventions for the files.
Secondly, if users are uploading files, you can store references to the images in a database. Store an id for the image and its location, for example id=1 location=someImageName.jpg and then pass the id of the image to the page i.e. /?imageId=1. Then do a select for the image location based on its id and print it out inside the <img> tags.
hth
I've hunted around the WP plugins and can't find one that would do the job, unfortunately.
Your idea though sounds perfect - as I do have control over the naming of the files and no users will be uploading files to the site.
I've only one question: Where do I add the new variable?
$imageFile = $_GET['var'] . ".jpg";