Sure you can, just enable the php filter module, and put the php code to do this in the body of the node. Make sure you set the format of the body to PHP and not plain text or html.
So if the image is in your theme folder, you can grab and display display it using:
<img src="<?php print path_to_theme() . "/files/image.jpg"; ?>" title='some image'/>
You can get all files within a directory using php's scandir function. This function will return an array of all files within your files directory, after which you can loop through this array and output all image files to the screen like:
$files = scandir("path/to/files/dir");
/*Unset the first 2 items in the array since they contain . and .. respectively */
foreach($files as $file)
Here we get the file extension
If the value of $file = "photo.jpeg"; this returns "jpeg"
$f_ext = end(explode(., $file));
/*Checking if file is an image*/
if($f_ext == 'jpg' || $f_ext == 'png' || $f_ext == 'gif'|| $f_ext == 'jpeg')
print "<img src='<?php print "path/to/files/$file"; ?>' title='some image'/>";
Hello, Joshua. I have gotten that far. If I have, for example, images that I have upload to my 'files' folder of my theme and I want to display all of them on one of my node pages, what is the PHP code I would use. Again, I am using Drupal 7 core. Thanks.
Thanks, Joshua. Is there a particular way to do this as an array. I want to try it displaying ALL the images contained in the files folder. I really appreciate your help.
Hi, Joshua. Sorry I keep bugging you with this. I can't get it to work properly. I tried the above code with no success. I'll list what I did to customize the code you supplied and give you the error that is showing. 1) I changed the path/to/files to the image path that I have tested and works, in both the variable above and in the print path . 2) I wrapped the code with <?php ?>. 3) I didnt change the if statement parameter at all, do I need to? this error contnues to show: Parse error: syntax error, unexpected T_STRING in theme-site\modules\php\php.module(80) : eval()'d code on line 8
Hey man, i don't mean to be disrespectful or anything. But if you can't understand the code above that i have updated, i would advise you to read a php book, preferable one that would take you from basic to intermediate. :) all the best