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

Static pictures transformation #4

Closed
si14 opened this issue Mar 6, 2017 · 6 comments
Closed

Static pictures transformation #4

si14 opened this issue Mar 6, 2017 · 6 comments

Comments

@si14
Copy link

si14 commented Mar 6, 2017

Hi there!

Quick question: how do you apply Cloudinary's transformation to static media? Did I miss something in the README, or is there no way to transform static pictures at the moment?

@klis87
Copy link
Owner

klis87 commented Mar 6, 2017

Hi,

You mean how to handle static images uploaded by collectstatic command? If that is the case, unfortunately all static files currently are uploaded as Cloudinary Raw type, which indeed is not always what you want, static images should be uploaded as images, static movies as movies.

So there is a need to distinguish between different types of static files. I guess the easiest would be to provide extensions for images and movies (and it would be configurable in settings.py). Those are files which web developer is in control of, so we really don't need to validate those (in contrast to media files).

After this, you could use pycloudinary template tags like for media files example in this package's readme:

{% load cloudinary %}
{% cloudinary test_model_instance.image.name width=100 height=100 %}

What do you think about this solution? If that is fine, I will implement this soon.

@si14
Copy link
Author

si14 commented Mar 6, 2017

Yeah, exactly! Cloudinary is awesome in that I don't need to come up with 4+ variants of the same image (x1/x2, jpg/webp) and can choose its resolution in the place of use. It would be nice to have the ability for static files, too.

I can't find any downsides in your solution. The only thing to add would be an ability to provide a general predicate over the path. It can be useful during gradual migration, like when you have both old and pre-compressed assets (those are better treated as "raw"), and new high-res ones.

Thanks a lot for your swift reply and a proposed implementation!

@klis87
Copy link
Owner

klis87 commented Mar 7, 2017

No problem, and yeah, I agree, transformations for static images are indeed a necessary feature :)

Could you please explain what do you mean by general predicate over the path? Some filter not based on file extension only? Could you give an example?

And why is it better to upload old and pre-compressed images as raw files, does Cloudinary make any optimizations for raw files?

@klis87
Copy link
Owner

klis87 commented Mar 12, 2017

I have just made new release. Please let me know if everything is covered now.

@klis87 klis87 closed this as completed Mar 18, 2017
@si14
Copy link
Author

si14 commented Apr 1, 2017

I'm really sorry for a delayed reply.

I didn't have the time to look into the feature yet (had a slight change in priorities), but I'll definitely do! Thanks a lot for making it a reality in such a short time, it's unbelievable :)

@klis87
Copy link
Owner

klis87 commented Apr 3, 2017

No problem :) I hope you will find this new feature useful :)

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