I'm using hook_image_default_styles() to define some image styles that I would prefer are uneditable and don't show up in any user interfaces. Basically these are specific thumbnails made to work within administrative interfaces. I had the thought that a key could be added to the image style info array that marks a style as 'private' or something. 'Private' image styles would be excluded from image_style_list, and ideally field formatters and other user interfaces.
I don't know if this falls within the scope of the current code freeze. If this is desirable, I'm glad to create a patch for it. If so, my only question is what the info key should be. I think 'private' would work, but if there any ideas for something that is more self-explanatory, I'm all ears.
Comments
Comment #1
te-brian commentedBumping this to see if theres any interest. Also, if something like this doesn't go into core, is it currently possible for contrib to filter user-facing image style options without individually form_altering tons of pages.
I guess the downside of something like this is that we don't really want a bunch of modules just using their own styles all over the place and not giving the user any option of changing or editing them.
Alternatively, is there currently any public facing API to output just one single "styled" image without creating a style first. Perhaps passing a style array into some theme function? I guess this has caching and redundant image processing consequences.
Comment #2
ksenzeeField API uses 'no_ui' for field types and 'locked' for fields. Probably that should be the same word in both cases but it isn't. I would tend toward using one of those two words, rather than 'private', which could cause confusion with private vs. public files. And I don't know that this is within the scope of D7, so I'm bumping it to D8. I do think contrib could form_alter it all out at once. Whether or not it's desirable is a discussion to have in the D8 cycle.
About outputting a styled image without creating a style first, my understanding is that there is no API for that, so that we don't expose a super-easy way to DOS a site.
Comment #3
claudiu.cristeaDue to the flexibility introduced in the image system you can now alter/overwrite/extend all image style UI components and ImageStyle itself. So. it wouldn't be a problem to write a contrib/custom module that handle that. You can extend, for example,
\Drupal\image\Entity\ImageStyleand add such field. Then extend\Drupal\image\ImageStyleListControllerand filter out those styles along with altering the route access check to disallow access to edit form for those styles.Closing.