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

Allow variants on file field #1948

Closed
Paul-Bob opened this issue Sep 14, 2023 · 7 comments · Fixed by #1964
Closed

Allow variants on file field #1948

Paul-Bob opened this issue Sep 14, 2023 · 7 comments · Fixed by #1964
Assignees

Comments

@Paul-Bob
Copy link
Contributor

Feature

From here

File field should allow variants, maybe like:

field :profile_pic, as: :file, format_using: -> {
  value.variant(resize_to_limit: [480, 480])
}
@adrianthedev
Copy link
Collaborator

adrianthedev commented Sep 15, 2023

You can add .processed at the end.

field :profile_pic, as: :file, format_using: -> {
  value.variant(resize_to_limit: [480, 480]).processed
}

@Paul-Bob please write to the OP and add a guide in the docs with a link from the field field.

Close this issue when you see fit.

Thanks!

@Paul-Bob
Copy link
Contributor Author

format_using: -> {
    value.variant(resize_to_limit: [28, 28]).processed.image
  }

This don't break the app but the image keeps original dimensions only with lower resolution, I think the expected output of a variation is to resize the image

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

This issue has been marked as stale because there was no activity for the past 15 days.

@adrianthedev
Copy link
Collaborator

Closing because you can use this

@Paul-Bob
Copy link
Contributor Author

Paul-Bob commented Oct 5, 2023

@adrianthedev check my comment here

This don't break the app but the image keeps original dimensions only with lower resolution, I think the expected output of a variation is to resize the image

The user want to be able to resize the image on the show view using variants not to keep the same size with different resolution.

field :cover_photo, as: :file, is_image: true
image

field :cover_photo, as: :file, is_image: true, format_using: -> { value.variant(resize_to_limit: [100, 100]).processed.image }
Result:
image

Expected:
image

I see that from previous messages and by the title of the issue it was not clear enough, originally the scope of the issue was to permit variants, than we noticed that variants can be applied followed by .processed.image but the result is different from the expectation.

@Paul-Bob Paul-Bob mentioned this issue Oct 9, 2023
4 tasks
@WvanLelyveld
Copy link

It would be great if this would be added to the documentation.

@Paul-Bob
Copy link
Contributor Author

Yes @WvanLelyveld this should be documented

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

Successfully merging a pull request may close this issue.

3 participants