ZGD

Secondary Image in Image Field

5 posts in this topic

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?

Share this post


Link to post
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

1 person likes this

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By horst
      Hi, here is a very useful tool that check your images in websites against responsiveness:
      https://github.com/ausi/respimagelint
       

    • By Brian Scramlin
      Hey Everyone,
      I have a question that seems like it would have an obvious answer, but I cannot wrap my mind around it:
      If I have 
      <img src="<?= $page->featuredImage->size(800,500)->url ?>"/> in an article template, does my server run a resizing script
      every time someone requests the page? Or, is it resized only the first time it is requested? Or when the page is saved? The reason I would like to know is because I have created two image processing functions my client requires, but one of them is a paid subscription service to compress the images. I don't want to call the paid API every time a page is loaded or something.
      Thanks for fielding my ignorance
    • By evanmcd
      Hi all,
      I've not been able to upload SVGs into a regular image field, with SVG added in the Valid File Extensions field.
      The error I'm getting is:
      Error: Call to undefined function ProcessWire\simplexml_load_string() (line 234 of /var/www/hosts/our_website/Develop/Source/wire/core/Pageimage.php) I tried the ImageRasterizer module, but that didn't fix it.
      Is there a workaround for folks that don't have the simplexml module installed?
    • By Ibrahim El Haddad
      Hi guys, 
      Yesterday, I faced a problems to run a processwire old system from backup locally, finally after your support, the system start working but still I have the below problems issues. 
      1. Once I try to press a sub-link, it guides me to Object not found, Error 404  similar to the below , and the link of the website became like below: 
      http://www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.localhost:9999/publications-and-ressources/texts/books/
      despite of that my application name is ibrahem, so if I amend the url manually to be as 
      http://www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.localhost:9999/ibrahem/publications-and-ressources/texts/books/
      it works fine, but every link, i should amend the url to add the application name. 
      Object not found!
      The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
      If you think this is a server error, please contact the webmaster.
      Error 404
       
      2. The images issues, that the images related to the book cover or another issue such as the slider is not appear, please advice.
       
      Thank you in advance for all of your support and help.