Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Add files to image gallery from CSV #2029

Open
gorgenarrows opened this issue Feb 17, 2025 · 2 comments
Open

[Feature Request]: Add files to image gallery from CSV #2029

gorgenarrows opened this issue Feb 17, 2025 · 2 comments

Comments

@gorgenarrows
Copy link

gorgenarrows commented Feb 17, 2025

Feature Description

The image gallery allows one to add files along with ALT text and a caption. In my case, I often have the ALT text and caption available before adding the images, and it would be easy for me to convert that information into a spreadsheet and export the data as a three column CSV specifying the filename, alt text, and caption.

From a UI perspective, this could be handled either by adding an "Import CSV" button on the Insert/Edit Gallery screen, or by enabling "CSV" as an option in the "Open Files" dialog.

Here's an example of a CSV that I made as part of bringing in an image gallery (though I'll have to copy and paste the ALT text and captions for 45 images by hand):

assets/images/20241221-214.jpg,Raindrops falling on the Gorge Waterway.,We are not deterred by a little rain!
assets/images/20241221-242.jpg,"A quad docking. Two rowers are visible, while a third helps bring them in by holding the oar.",Back on the dock.
assets/images/20241221-240.jpg,A quad docking. One rower is visible and is wearing a hat with antlers. The picture is taken through a crowd of people on the dock.,Back on the dock.
assets/images/20241221-241.jpg,A quad docking with three festively dressed rowers visible.,"And off to join the festivities (or get ready for another

I think this would be a generally useful feature, and would provide a way for image galleries to integrate with a great number of external image management tools. For example, it would be easy to extract the "Title" EXIF field from the image metadata and use it as either the ALT text or the caption.

@gorgenarrows
Copy link
Author

Note: in case anyone else has a similar problem, it's possible to get a similar effect by:

  1. Renaming all the input files so they list in the correct order (e.g., 001-fu.jpg, 002-bar.jpg, etc.)
  2. import all of the images into the gallery.
  3. Go into HTML mode in the image gallery.
  4. Copy the gallery and paste it into a file.
  5. Use a tool like the Linux "tidy" command to make the output proper XML (e.g., tidy -q -asxml --numeric-entities yes input.xhtml > output.xml)
  6. Use a tool like 'yq' to extract the information as a CSV.
  7. Add the alt text and captions to the extracted CSV.
  8. Use 'yq' to read the CSV and generate the XML.
  9. Paste the XML back into the post.

It was not pretty, but it will be faster than entering everything by hand the next time this comes up!

@candidexmedia
Copy link

This is a great suggestion and workaround!

In the meantime, someone made an ALT text plugin which uses the file name:

https://github.com/gpsblues/Publii-Plugin-Alt-Filler

It doesn't have options for captions, though, but the plugin author might be open to suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants