Jump to content

Directory fieldtype to select a folder and output its content?


bytesource
 Share

Recommended Posts

Hi Everyone,

I currently use the images fieldtype to upload and output images. As I sometimes need to upload many images per page, and each page's images are stored in a separate folder, I would like to know if there fieldtype that allows me to select a folder and stores its items in an array that I can loop through in the template?

Link to comment
Share on other sites

Greetings bytesource,

If I understand you correctly, you just need to create a field of the type "image" and allow the user to upload as many images as you want.

Let's say this field is called "gallery_images." You can make the call in the template as follows:

<?php
foreach ($page->gallery_images as $image) {
?>
<img src="<?php echo $image->url; ?>" />
<?php
}
?>

Thanks,

Matthew

EDIT: Sorry, I didn't respond to the part about the folders! Again, if I understand what you're asking correctly, you don't need to specify the folder, because ProcessWire takes care of that part for you. Just accessing the field via $page gets the rght images.

Link to comment
Share on other sites

Hi Mathew,

Let's say this field is called "gallery_images." You can make the call in the template as follows:

<?php
foreach ($page->gallery_images as $image) {
?>
<img src="<?php echo $image->url; ?>" />
<?php
}
?>

That's how I am doing it right now. What I wanted to ask is if there is a way to just specify a folder instead of uploading every single image one by one. However, I just realized that I can select more than one image at a time, thus turning the once repetitive task of uploading images into a one-time task.

  • Like 1
Link to comment
Share on other sites

Hello bytesource,

... However, I just realized that I can select more than one image at a time, thus turning the once repetitive task of uploading images into a one-time task.

Yes, I also overlooked this feature when I first started using ProcessWire. But then I found it, and it makes a big difference in adding photos. Like everything else in this system, it's as much as we need without adding more than we need.

Thanks,

Matthew

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...