Does anyone know if there is a way to set a maximum number of photos per album? Either in the 6.x or 8.x.5.x version of the module?

Comments

Frontmobe created an issue. See original summary.

nathaniel’s picture

Category: Support request » Feature request
Status: Active » Postponed (maintainer needs more info)

I don't think the setting exists. It could probably be added fairly easily though. We'll have to update the PhotosUpload service and the validation for the photos_image entity form to display a message that the maximum number of images for the album has been reached and prevent new images from being added.

On /admin/config/media/photos we can add a setting under upload or maybe under album limit called "Maximum number of photos per album".

Any other ideas for functionality / wording?

frontmobe’s picture

Hi Nathaniel,

Thanks for your quick feedback, I think that would be a great way to add the functionality of setting a maximum number of photos per album.

I attached an elementary patch that updates the PhotosUpload service and validation for the photos_image entity form, like you mentioned. To keep things simple, I set $album_max_size in the code for now but setting that value in the module config at /admin/config/media/photos under "Album limit" definitely sounds like the way to go.

One thing that still puzzles me is that although I include "return FALSE;" in the service, the image still is created as a Drupal file on the file system. The image is not included in the album (due to the validation in the form), but returning FALSE when $photocount exceeds the maximum number of photos per album does not prevent the creation of the Drupal file. Do you have any suggestions on how to solve this?

Especially when using plupload to upload a large number of photos, this would otherwise mean that still many Drupal files would be created even though the limit is exceeded.

Have a good weekend!

nathaniel’s picture

Status: Postponed (maintainer needs more info) » Needs review

Changing to needs review.

nathaniel’s picture

StatusFileSize
new14.08 KB

Good start, thanks for the patch!

Added the option on /admin/config/media/photos under "Album limit". Made some changes and added some functionality throughout the various upload options.

Looks like I need to do a little more cleanup and dependency injection, but let me know if the functionality works now?

frontmobe’s picture

Hi Nathaniel,

I can confirm the functionality in the patch works perfectly! The config under /admin/config/media/photos -> "Album limit" is clear and the added messages are too. Uploading more images than allowed now also does not result in Drupal files being created for the excess images, which keeps things tidy. This works when using Plupload or using the default file widgets on the upload form.

From a functionality standpoint I would say this is now complete, thank you for working on this so quickly!

Cheers,
Marco

frontmobe’s picture

Status: Needs review » Reviewed & tested by the community

  • Nathaniel authored fe43ee0 on 6.0.x
    Issue #3213819 by Frontmobe, Nathaniel: Maximum number of photos per...
nathaniel’s picture

Status: Reviewed & tested by the community » Fixed
nathaniel’s picture

Note: when updating to the latest dev cache may need to be cleared.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.