lib/fleximage/model.rb
# Execute image presence and validity validations.
Execute image presence and validity validations.
Execute image presence and validity validations .
def validate_image 
        field_name = (@image_file_url && @image_file_url.present?) ? :image_file_url : :image_file
        if @invalid_image
          errors.add field_name, self.class.invalid_image_message
        elsif self.class.require_image && !has_image?
          errors.add field_name, self.class.missing_image_message
        elsif self.class.validates_image_size && !@uploaded_image.nil?
          x, y = Fleximage::Operator::Base.size_to_xy(self.class.validates_image_size)
          if @uploaded_image.columns < x || @uploaded_image.rows < y
            errors.add field_name, self.class.image_too_small_message
          end
        end
      end
def validate_image field_name = ( @image_file_url && @image_file_url . present? ) ? :image_file_url : :image_file if @invalid_image errors . add field_name , self . class . invalid_image_message elsif self . class . require_image && ! has_image? errors . add field_name , self . class . missing_image_message elsif self . class . validates_image_size && ! @uploaded_image . nil? x , y = Fleximage :: Operator :: Base . size_to_xy ( self . class . validates_image_size ) if @uploaded_image . columns < x || @uploaded_image . rows < y errors . add field_name , self . class . image_too_small_message end end end
Execute image presence and validity validations.
Execute image presence and validity validations .
#:nodoc: # Could not read the file as an image # no image uploaded and one is required # Image does not meet minimum size