2

We have hundreds of photos on our theater website from past performances. In order to sustainably manage the relationship between cast members and which photos they were in, we wanted to explore setting up some type of tagging system. Would there be a way to associating a person (Entry type) with a photo (Asset Type) at the asset level? That way, we could query the database for any photos a person is in from their bio page and assemble them into a slider. Image Slider via FlexSlider

2
  • Can you submit your solution as an answer instead of part of the original question? It's a little easier to understand for other users with similar questions. This is a perfectly acceptable and encouraged on Stack Exchange. – Alex Roper Apr 21 '15 at 7:04
  • Alex, I went ahead and changed it to an answer. – jsilton Apr 21 '15 at 13:05
2

Assets can have custom fields just like entries. You can create an entry field for the person section, and add it to the asset source field layout from your asset settings.

You can then use relations to query for the right assets or entries as you see fit!

1
  • Great! Thanks for posting the solution :) – Aaron Berkowitz Apr 20 '15 at 3:06
1

I tried putting together the code, and resolved the issue. Here's the solution for anyone else out there looking to do something similar:

The asset handle is "productionPhotos". enter image description here

Within "productionPhotos", there is a field "imageTags" so that I can add multiple people as tagged in the photo. I used a Matrix field type. The block type name is "person" and the Field name is "taggedPerson" with a field type of "Entries". enter image description here

Here's the code I used:

<div id="slider">
  {% set photos = craft.assets.section('productionPhotos').relatedTo({
    targetElement: entry,
    field: 'imageTags.taggedPerson'
   }) %}
  <ul class="slides">
    {% for image in photos %}
    <li><img src="{{ image.getUrl('sliderImage') }}" alt="{{ image.title }}" /></li>
    {% endfor %}    
  </ul>
</div>

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.