summaryrefslogtreecommitdiff
path: root/app/models/diff_viewer/image.rb
blob: fca6c6641967d21a8aaf0ce70e410d7a45f9610c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module DiffViewer
  class Image < Base
    include Rich
    include ClientSide

    self.partial_name = 'image'
    self.extensions = UploaderHelper::SAFE_IMAGE_EXT
    self.binary = true
    self.switcher_icon = 'doc-image'
    self.switcher_title = _('image diff')

    def self.can_render?(diff_file, verify_binary: true)
      # When both blobs are missing, we often still have a textual diff that can
      # be displayed
      return false if diff_file.old_blob.nil? && diff_file.new_blob.nil?

      super
    end
  end
end