1

Is it possible to search a server folder containing image and video files that were previously uploaded via ftp and then loop through those files in the entry template?

Each entry has a unique Log ID number field which is also part of the image or video filename.

Example:

  • Log ID: 12345
  • Image filename: 12345-[8374]-img-01.jpg
  • Image filename: 12345-[8374]-img-02.jpg
  • Video filename: 12345-[8374]-vid-01.mp4
  • etc...

Conceptually on the template page...

  • Grab the entry LogID field (ex. "12345")
  • Search the media server folder for all filenames that begin with the LogID
  • Display all of the found images and videos

I found this question which is very similar but I don't have the skills to write a plugin.

  • Any reason you couldn't Settings->Tools->Update Asset Indexes after every FTP upload and deal with the uploads as proper Craft Assets? – Brad Bell Jul 6 '17 at 23:23
  • @BradBell do you mean then open each entry and attach the uploads? If that's what you mean, I could, but we upload about 200 files every week for about 50 preexisting entries. I was hoping that there may be another way to do it automatically. – Lori Jul 7 '17 at 1:10
  • Well... there is, but it's going to require a plugin. :) I can't think of any other way. – Brad Bell Jul 7 '17 at 3:57
  • @BradBell I wonder if I misunderstood your initial suggestion about using "Update Asset Indexes" tool. If I index the files so they exist in the database, they can be searched, correct? So in my template, could I grab the LogID field value from the page entry and then used that value to search the assets folder for filenames that contain that LogID? – Lori Jul 8 '17 at 14:12
1

I figure out a solution thanks to Brad's suggestion to update the asset indexes. That allowed me to find all assets on the server that contained a partial match to my LogID number which I am passing in a URL string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.