We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49748
    • 10 Posts
    I need to store author of each image (and display it). What is the best approach for that?

    Do I really need to create custom media source type?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      There are several ways you could do this. How many images are we talking about? How are they getting uploaded?
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 49748
        • 10 Posts
        Several thousands images. Uploaded 10-100 per day. Via multiple files upload. One by one or package of files at once.

        And they will be used in resource pages (news) or in photo gallery.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Unless these images are in a format that allows metadata, and has this information in the metadata, there is no way to do it.

          Well, there might be one way. Are a given author's images uploaded into their own folders? In that case, if the folders are named with the artist's name you could use a snippet to get the folder name. Or if the folder name is based on a given resource, and that resource has the author's name in one of its fields or even a TV, or if the folder is based on a username or user ID... do you see the idea here? (I was going to say, do you get the picture? but that would be too obvious!) There has to be some way of associating the images with the author.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            As far as custom media sources, the MIGX package comes with a very nice snippet, migxResourceMediaPath, for creating variable Media Sources from just one Media Source. For the path and URL, just put
            [[migxResourceMediaPath? &pathTpl=`assets/images/{id}/`]]

            There are a couple of options, you can have it create the {id} folder if it doesn't already exist with &createfolder=`1`.

            You can use these resource fields as folder names:

            • {pagetitle}
            • {alias}
            • {parent}
            • {ultimateparent}
            • {templatename}
            • {breadcrumb}
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 49748
              • 10 Posts
              Quote from: sottwell at Jan 30, 2015, 12:39 AM
              Unless these images are in a format that allows metadata, and has this information in the metadata, there is no way to do it.

              Thanks sottwell. I've got your idea. Considering author association to image, there is really no such problem. They can enter it to each image in modx after upload. I was thinking about creating new media source type, based on gallery (which already have additional fields for each image) and extend it with author field.

              To be honest, I was a little surprised that image is just file on modx. Without any database association.

              Using a folder name is a trick doing the job, but for this situation I think is not good. I do not want editors to think about real paths.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org