title: Detect file type and resize if image
body: <p>I have model Attachment whitch supprted pdf's and images. How to detect if its image and only then resize it ? When it's paperclip everything Was simple. but now ? ;)</p>
  
  <pre><code>class Attachment &lt; ActiveRecord::Base
  
          has_attached_file :attachment,
                  styles:          lambda { |a| a.instance.is_image? ? {:small =&gt; "x200&gt;", :medium =&gt; "x300&gt;", :large =&gt; "x400&gt;"}  : {:thumb =&gt; { :geometry =&gt; "100x100#", :format =&gt; 'jpg'}, :medium =&gt; { :geometry =&gt; "300x300#", :format =&gt; 'jpg'}}},
  
          def is_image?
                  attachment.instance.attachment_content_type =~ %r(image)
          end
  
  end
  </code></pre>
  
  <p>How to make something like above with active storage ? I try like this:</p>
  
  <pre><code>class Attachment &lt; ApplicationRecord
    has_one_attached :file
    validates :file, presence: true
  
  def file_url
  if ???? (is image?)
  rails_blob_url(file.variant(resize: '1920x1920').processed)
  else
  rails_blob_url(file)
    end
  end
  </code></pre>