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

Focuspoint, use resize instead of thumb #106

Open
PubliAlex opened this issue Oct 6, 2023 · 2 comments
Open

Focuspoint, use resize instead of thumb #106

PubliAlex opened this issue Oct 6, 2023 · 2 comments

Comments

@PubliAlex
Copy link
Contributor

PubliAlex commented Oct 6, 2023

Hello,

The focuspoint use the old thumb method of october to resize images. It would be great to update it and use the resize method instead.

The biggest benefit of the switch is that resize method accept fileupload object AND path string.

I think the best solution would be to keep the |resize filter, and add focuspoint styles if the image is a fileupload widget that use focuspoint. Like that, your frontend syntax don't change even if you add focuspoint to a fileupload widget later.

If it's not possible, would be great to have a |focus filter that would behave exactly like the |resize filter, but that would add focuspoint features to fileuploadwidget that use it (but also accept a simple string path like the |resize filter)

What do you think about it ?

@tobias-kuendig
Copy link
Member

I'm not sure I understand your suggestion correctly.

Currently, focuspoint only works with File models. This is required, since we need to store the focus point data somewhere.

You output the file now using file.focus(). What would be the benefit of using a | resize filter here?

The biggest benefit of the switch is that resize method accept fileupload object AND path string.

I see that benefit, but you'll never get a focuspoint image as a string since it only works with File models.

@PubliAlex
Copy link
Contributor Author

PubliAlex commented Oct 12, 2023

Yes, I understand that focuspoint can only work with file model, you need that popup to place the point, and it's not available outside file model.

The idea in the thread is more to keep the same syntax when you want to resize images, fileupload or not, focuspoint or not.

For example, I use a partial for my image, to avoid code repetition, I prefer to call a partial like this :

          {% partial 'image' image = image width = 500 height = 500 mode = 'crop' %}

And then, in my partial have

         <img class="lazy" src="{{ image|resize(width / 10, height / 10, {mode: mode}) }}" data-src="{{ image|resize(width, height, {mode: mode}) }}" alt="{{ image.title }}" />

But, when I deal with focuspoint, I have to add some conditions to use .focus instead of |resize, that's not ideal.

Another small benefits of overriding |resize is that I'm not sur that thumbnails have the same save logic in october, and using the same would make cache cleaning easier (console command tu purge thumbs etc...)

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