I'm trying to call a JPG file from within PHP (in an effort to hide the actual JPG folder. The image is supposed to be called at domain.com/photo/?id=X&i=Y where X is the post ID and Y is the image number, but it doesn't seem to be working. I've done this before but copying and pasting the code doesn't seem to be working. What am I missing?
<?php
/*
Template Name: image
*/
if (is_page()){
if (isset($_GET['id']) && isset($_GET['i'])) {
$post = get_post($_GET['id']);
$gallery_path = mhp_get_gallery_filepath($post).'/'; //get 'secret' folder location of photos
$imgs = (mhp_img_list($gallery_path)); //return filenames of all jpgs in folder
$img = $imgs[(int) $_GET['i']]; //get name of i-th jpg file
if (file_exists($gallery_path.$img) && is_readable($gallery_path.$img)) {
header('Content-Type: image/jpeg');
$orgimage = imagecreatefromjpeg($gallery_path.$img);
imagejpeg($orgimage, NULL, 90);
imagedestroy($origimage);
}
}
}
?>