Jump to content

Secondary Image in Image Field


ZGD
 Share

Recommended Posts

I'm currently developing a site where some image fields need to be able to have two images associated with them, a thumbnail and a full sized image (which is often a different crop) which will be shown in a lightbox view.

This is fine for most templates, I'm just using normal image fields that return an array and support up to two images. If a second image is present in the field then it will be used as the alternative image for the lightbox. If only one image is present, it will be used for both thumbnail and full sized (the template resizes for the thumbnail using the API). However I have templates with flexible layouts using a repeater matrix, and one of the matrix types is an 'image grid'. This is an image field that supports an unlimited number of images, so obviously this method is not suitable here.

I've tried creating a repeater in this matrix type which contains an image field (each supporting two images, as above), but this means that I can no longer drag and drop multiple images at once. Each image in the grid has to be uploaded individually which is a big problem as there are many instances of these grids with a large number of images.

I've tried the ImageExtra module but it seems you can't add an image field as a secondary field.

Any suggestions as to how I might solve this problem?

Link to comment
Share on other sites

1 hour ago, ZGD said:

I've tried creating a repeater in this matrix type which contains an image field (each supporting two images, as above), but this means that I can no longer drag and drop multiple images at once.

Are you saying that an images field inside a repeater does not allow drag-and-drop uploading? I'm not aware of any such limitation and with a quick test it seems to be working for me, even inside nested repeaters.

I think you should check out the Croppable Image 3 module for managing your different crops.

https://github.com/horst-n/CroppableImage3

  • Like 1
Link to comment
Share on other sites

12 hours ago, Robin S said:

Are you saying that an images field inside a repeater does not allow drag-and-drop uploading? I'm not aware of any such limitation and with a quick test it seems to be working for me, even inside nested repeaters.

Nope not quite, sorry I probably wasn't very clear there. Drag-and-drop does indeed work inside repeaters, my problem is that if I need to separate each image and its associated crop in the image grid into a separate repeater with an image field then I can't drag-and-drop say 20 images at once. I have to manually drag each image to the associated field in the repeater array.

An ideal situation would be the ability to store a secondary image with each image. For example each image has an input for alt text, I would somehow like there to be another input for another image. Essentially nested images.

CroppableImage3 is great but it also won't work for this as the images are prepared outside of PW as they have various other applications. The crops also aren't systematic and we also need to support the option for the crop being a completely different image entirely.

Link to comment
Share on other sites

What you want the system to do is simply not possible with core features. Image fields are file storage fields and even the description for them is more of a convenience functionality rather than a good way to store information. I've not used ImageExtra by now, so I'm not sure how it does save it's additional data, but it seems it doesn't do what you need as well.

For such an image grid you should still go with single pages holding the image / thumbnail and additional info. Maybe you can use a pagetable to display those imagepages and keep the convenience of drag&drop / nice overview over items, which is not so nice with repeaters.

17 hours ago, ZGD said:

Each image in the grid has to be uploaded individually which is a big problem as there are many instances of these grids with a large number of images.

If this is the case, how does that go together with each/lots of those images having custom made thumbnails as well? It probably either going to be a lot of manual uploading work or you strip the feature of custom thumbnails. If both is not possible you probably wont get around building something custom to create those grids.

Link to comment
Share on other sites

Thanks @LostKobrakai. That all makes sense.

28 minutes ago, LostKobrakai said:

If this is the case, how does that go together with each/lots of those images having custom made thumbnails as well? It probably either going to be a lot of manual uploading work or you strip the feature of custom thumbnails. If both is not possible you probably wont get around building something custom to create those grids.

I'd estimate less than 5% of images will have alternatives, so the manual uploading for those would be manageable. Being able to drag and drop multiple images at once is really the priority, but I had a better look through all the core modules earlier and decided the development time to create something custom probably wasn't worth it for this project. I looks like we will have to go with a repeater or pagetable approach as you've suggested.

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

×
×
  • Create New...