0

I am writing a theme for a client where the employees sometimes have trouble using Wordpress correctly. I am using custom fields to let them add a gallery to a portfolio item (which is just a custom post type). Sometimes they just add images instead of a gallery, which is possible since the field in the portfolio is just a WYSIWYG Editor field with ACF. That is a problem because the layout is not working then.

The client now asked if it was possible to only allow them to add galleries. And not single images.

Is there a way to do that? Has anyone ever seen something like that? I know, it is ridiculous, but maybe there is a way...

  • I think that if the employee wants to add an image instead of the gallery and you want to force him to do a gallery, then he is right and you are wrong. How hard is it to detect that an image is inserted and make it behave like a gallery? – Mark Kaplun Nov 26 '15 at 18:45
  • Well, wrote a custom gallery plugin and I am using different image sizes for thumbnail previews and smooth transition. So it isn't just about displaying a couple of images. – Øle Bjarnstroem Nov 26 '15 at 18:47
  • obviously your workflow is too difficult for the client. In the end the client is the one that uses the software Maybe you are trying to do more then what he actually needs. – Mark Kaplun Nov 26 '15 at 19:19
  • I would really appreciate an answer to my question and not a critique on my general approach. Is it possible to only allow galleries? However achieved. Alternatively you could tell me a good way how I magically build a gallery from inserted images without using the shortcode - but only if the client did by accident not use the gallery. You see, the easiest way to deal with this is to limit the input. – Øle Bjarnstroem Nov 26 '15 at 19:31
  • 1
    To make it more clear: I am open to critique. But I strongly dislike the answer style where people tell you nothing but "you are doing it wrong". This might be right, but a good answer is "this is a better way". – Øle Bjarnstroem Nov 26 '15 at 19:34
2

I'm used to deal with ACF configurations and I think that the solution to your problem is quite simple, and is integrated in the ACF "gallery" field configuration options.

Check out this link, where you will find described all the options for a "gallery" field. As you will see, there's a parameter "minimum selection" which description is:

The minimum number of images that are required for the field to validate. Defaults to 0

As simple as writing '2' in the configuration panel for this specific field, and ACF will check before saving if there are two or more images. If not, an alert message will appear.

I hope it helps!

  • It is noteworthy that this only exists in the pro version. But YES, that was what I was looking for. Thanks! – Øle Bjarnstroem Nov 26 '15 at 23:05

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.