Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets: Global Rules/Validation + CP Default Rules #619

Closed
benlilley opened this issue Aug 11, 2021 · 4 comments · Fixed by statamic/cms#10227
Closed

Assets: Global Rules/Validation + CP Default Rules #619

benlilley opened this issue Aug 11, 2021 · 4 comments · Fixed by statamic/cms#10227

Comments

@benlilley
Copy link

Recently we had a content editor accidentally upload a large .psd file directly into the CP via the Assets screen. This mean that all the individual field validation rules were ignored. This made me think of a couple of suggestions:

  • It would be nice to be able to set default/global validation rules for uploads that apply to the CP
  • Groups or sets of rules that can be shared across fields, so I could set validation rules for 'Large Images' or 'Videos' apply it to certain fields without having to copy/paste or update rules across all uses of the field after the fact.

Very much a nice to have, obviously not a big issue.

@jasonvarga
Copy link
Member

We've mentioned this plenty of times but I can't find an issue for it.

The idea was to always be able to add validation rules to the container.

@stuartcusackie
Copy link

stuartcusackie commented Jun 14, 2022

I would go further to say that this is a medium sized issue. If you've ever tried processing a 20mb image with glide and generating reponsive sizes / fallbacks you might see a website grind to a halt for a while, and possibly crash a server / require a restart.

Also, are PHP validation rules what we need here? In an ideal situation I would catch the large file size with JS validation before sending it to the server or to cloud storage.

Just some thoughts.

@jasonvarga
Copy link
Member

That's a good idea too. To stop the large file getting to the server in the first place. 👍

@stuartcusackie
Copy link

stuartcusackie commented Jun 20, 2022

While we're on the subject, there are a couple of more validation rules that would help me avoid asset related crashes:

  • File type: A client uploaded a PDF to my 'images' container, and glide crashed the website when trying to make a thumbnail from it. A list of allowed file / mime types would prevent this.
  • File name: A client uploaded a file with a very strange name - it included semicolons (which I think conflict with Statamic's asset ids) and lots of full-stops. Again glide crashed when trying to handle this file. Regex filename validation would prevent this, or maybe just prevent semi-colons in filenames globally.

I've been reading other issues and requests from v2 and there are concerns about resizing originals on upload - with some stating that they think original sizes should be kept. Container validation rules should keep everyone happy, giving you the option to resize / restrict or not. I wonder though, would it be possible to always keep the original file, generate a smaller size where necessary and then use that smaller size for glide generation, i.e. the original massive file would be kept but a smaller version would be used by glide for performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants