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

Toggle lazy-load in the project's settings #101

Open
fitodic opened this issue Oct 12, 2016 · 6 comments
Open

Toggle lazy-load in the project's settings #101

fitodic opened this issue Oct 12, 2016 · 6 comments

Comments

@fitodic
Copy link
Contributor

fitodic commented Oct 12, 2016

Greetings!
Firstly, great job developing this library!
Secondly, the documentation states that the adjust tag renders as a URL to the adjusted image as lazily as possible. This is a great feature, but have you ever considered setting the generate parameter project-wide?

To make thing clearer, here's an example. A site allows the users to upload their own images and there is a predefined set of variations that can be diplayed, e.g. only thumbnails of 300x200px and 600x400px. The process of generating these variations can be triggered after uploading the image.

In order to be backwards compatible, this setting could be set in the project's settings and the default value would remain False. Therefore, if the project does not have the variable set, it would maintain its previous functionality.

We already have a working example. I'd be happy to implement it and send you a pull request.

What are your thoughts on the matter?

Sincerely,
Filip Todic

@melinath
Copy link
Owner

Have you already looked at daguerre-preadjust? Does it meet your needs?

It sounds like you're looking for a solution that does the adjustment creation when the image is uploaded rather than when it's loaded, so a cron solution might not be exactly what you're looking for. Rather than just adding the GENERATE setting, I'd probably want to see something that's hooked into DAGUERRE_PREADJUSTMENTS, for example by adding a DAGUERRE_PREADJUST_ON_SAVE setting and adding a post_save listener that applies all relevant adjustments.

@fitodic
Copy link
Contributor Author

fitodic commented Oct 13, 2016

Thanks for the feedback!
We've analyzed the situation in detail. Unfortunately, none of the currently available solutions meet our needs. We are not able to customize our custom logic at the moment to the point of providing a generic solution that could be pushed upstream.

Baring that in mind, I suggest we close this issue for the time being. Thanks for your help!

@melinath
Copy link
Owner

Eh, It's still a useful ticket. I'd be curious to know more about your use case if it's something you'd be willing to share?

@fitodic
Copy link
Contributor Author

fitodic commented Oct 14, 2016

We use daguerre's adjust tag in several places and a global generate=True settings suits us because:

  1. We have a large user base that produces its own content (including images). They are free to publish whatever they want, whenever they want (within the bounds of the law of course). We have no control over the published content, and the only requirement is that they see the results, i.e. variations, in near real-time. Furthermore, the machinery we have in place is capable of handling that load.
  2. The lazy-rendering feature results in caching issues and is therefore not an option. The generated AJAX URLs are cached and for a while (the duration depends on the cache settings of a particular tag), the users are receiving these URLs instead of the real ones. This violates the requirement mentioned above. Furthermore, this is also an SEO issue, meaning that the same content (in this case an image) has different URLs.
  3. A cronjob calling the preadjust command would not be suitable for both production and development purposes. The production requirements are already explained above (issue 1.). As to the development requirements, frontend developers are free to set any dimension parameters they choose. Even if we know most of the variations, there is no way of anticipating their needs.

@melinath
Copy link
Owner

When you say the AJAX URLs are cached, do you mean that your site is using django {% cache %} tags? Or do you mean cached in the browser? Or something else? Are images maybe being updated in place, i.e. so that the same storage path would point to two different images?

There is definitely not an intent on our end that those URLs should be cached anywhere. The lazy rendering should work just fine for near real-time viewing of image variations. (I'm not addressing the SEO side of things intentionally right now because that's less high priority than a potential caching issue.)

@fitodic
Copy link
Contributor Author

fitodic commented Oct 18, 2016

When using template tags, we are using Django's template fragment caching as described in the official documentation. When the template was first compiled/rendered, the first URL that the template tag received was cached for the period of time specified in the cache tag.

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

No branches or pull requests

2 participants