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

Allows skipping files during the transformation #208

Closed
wants to merge 1 commit into from

Conversation

jni-
Copy link
Contributor

@jni- jni- commented Aug 2, 2017

Use case :

I want all media files to be handles through arc, but images need to
have 3 versions (:original, :thumb, :viewable) and videos simply need to
have :original and :thumb (since :viewable is just a low-res image that
acts as a place holder). Maybe I'm creating problems for myself by
handling videos and pictures all in one, but I feel like this could be a
nice addition.

Still quite new to the elixir world, so I may not have used a proper
technique to do the test. It doesn't feel quite right.

Use case :

I want all media files to be handles through arc, but images need to
have 3 versions (:original, :thumb, :viewable) and videos simply need to
have :original and :thumb (since :viewable is just a low-res image that
acts as a place holder). Maybe I'm creating problems for myself by
handling videos and pictures all in one, but I feel like this could be a
nice addition.

Still quite new to the elixir world, so I may not have used a proper
technique to do the test. It doesn't feel quite right.
@MartinElvar
Copy link
Contributor

@stavro Just a friendly ping, this is greatly need. :)

@pedep
Copy link
Contributor

pedep commented Jan 9, 2018

Am i correct in my understanding of this PRs intention, that you wish to add conditionals to the transforms, allowing you to have the same functionality as :noaction, but without the file being persisted to storage?

Like this?

def transform(_, {file, scope}) do
  if is_image(file) do
    {:convert, [...]}
  else
    :skip
  end
end

If the intention is to skip uploading certain versions, what is the intended behavior when a skipped version is requested MyDef.url({file, scope}, :skipped)?

@jni-
Copy link
Contributor Author

jni- commented Jan 9, 2018

@pedep Yes this was exactly my intention.

In my case I treated the case in the logic (if it's a video, it doesn't attempt to use that intermediate format). I can see how this could be problematic however.

On one hand I believe that if your logic dictates skipping this format, then it must equally dictates not to display this format. In this case the :skip is fine.

Alternatively, this could be changed to {:fallback, :other_format} which would make MyDef.url() consistent across all formats, it's just that MyDef.url(_, :skipped) and MyDef.url(_, :other_format) would return the same image.

What do you think? Should we keep it at :skip, or go for :fallback?

@pedep
Copy link
Contributor

pedep commented Jan 9, 2018

I think both are useful, but since the :skip option was intended to be handled by application logic, i think :fallback provides the same functionality (ability to just ignore the output of MyDef.url() in the case of a skipped version via application logic) along with providing the ability to define fallbacks / aliases

@jni-
Copy link
Contributor Author

jni- commented Jan 9, 2018

Yeah your comment made me realize that :skip was a specific case of :fallback or :alias. I'm in the middle of grading exams right now so what little remains of my 24h I try to sleep, but I'll give this a shot later this week. Thanks for the idea!

@pedep
Copy link
Contributor

pedep commented Jan 9, 2018

No problem 😄

@stavro
Copy link
Owner

stavro commented Oct 4, 2018

Fixed via de0bcc2. Thank you!

@stavro stavro closed this Oct 4, 2018
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 this pull request may close these issues.

4 participants