-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add task to pre-warm image cache #492
Comments
My thinking is that you could have a task that will call each page in your site tree with an alternative template. That would generate all the images for you. Once the task is done, you deploy your site with the alternative template on by default. There's probably alternative approaches worth considering as well. |
Not sure what this means... how is the template defined? How can we know that the template has all the variants from the website's theme templates? Or is this intended to catch all of the variants defined in PHP files? |
When you do a call like One way we could do this, is have custom implementation of <picture>
<source srcset="$Me.WebP.Url" type="image/webp">
<img $AttributesHTML />
</picture> Maybe that template is disabled somehow, but your task can enable it. |
Another question is what to do for project that have custom controllers that don't map to any SiteTree. Do we want to add a way for that task to discover those pages, maybe an extension hook on the task itself? |
Ahh, okay. So this task runs under the assumption that sites are using the default template? That's fair. There are definitely people using The task will also either have to be told how to traverse all logic branches which lead to different images, or else the documentation clearly state that images under branching logic may not have their variants pre-generated. |
If you are manually writing |
We integrate custom |
I wouldn't say it's a horrible practice to manually write your own picture/img tag. But it does come with the downside that it undermines some of the CMS capabilities. But if the CMS doesn't give you the tool to achieve the outcome you want, you got to do what you got to do. We should aim to make sure that our Image implementation has all the APIs people need to implement common use case, and make sure people are aware of some of the pitfall if they chose to write their own tags. |
I think one of the main issues is, as Michal alluded to, the fact that WYSIWYG images don't use the same template as relation images, so it's hard to have a clean way to customise the way images render on a site. That's covered by silverstripe/silverstripe-cms#2735 in this same epic. Another fairly common situation I've seen is the desire to use BEM or other specific css naming conventions that require a different class selector on images in different scenarios (e.g. you may have a card and a banner, and you want I don't think this is something that can currently be done with the built-in image template. All that to say: There will be edge cases this task won't catch. I think that's fine - in fact it's inevitable. We just need to document it in whatever documentation introduces the task, so that developers will be aware of what it does or doesn't do. |
Thanks, Guy, that sums it up well. On some projects, we even went as far as disabling the TinyMCE image plugin and only used images via has_one/many_many from blocks/pages to have the best control over things from the design implementation perspective. We didn't want users to put images just anywhere they wanted to break the visual aspect of the sites. There's definitely a use case for that and if it was made easier to customise the insertion modal to be able to provide custom controls and then render them using custom templates, it would surely be closer to being more usable for more devs directly from the WYSIWYG, so I'm supporting this work, it's a good step forward. |
If the rendering was done through an overridable method (or via an extension point), using an overridable template, that'd be the best — could be customised per WYSIWYG/per relation/per data model or controller. |
As server administrator, I want the ability to create image variants progressively prior to new image template being deployed.
Acceptance criteria
Note
We explored a similar concept on an internal project.
The text was updated successfully, but these errors were encountered: