Class: Simplec::EmbeddedImage

Inherits:
ApplicationRecord show all
Defined in:
app/models/simplec/embedded_image.rb

Overview

An embedded image in an editor field.

For the most part you don't need to utilize this record. These records are created by summernote and the administration of creating them is handled by the Simplec Engine.

There is an #embedded_images association on a `Simplec::Page` record.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assetDragonfly::Model::Attachment?


23
# File 'app/models/simplec/embedded_image.rb', line 23

dragonfly_accessor :asset

#asset_nameString?


# File 'app/models/simplec/embedded_image.rb', line 34

#asset_uidString?


# File 'app/models/simplec/embedded_image.rb', line 31

#embeddableObject?

The object that owns the embedded image


17
18
19
# File 'app/models/simplec/embedded_image.rb', line 17

belongs_to :embeddable,
polymorphic: true,
optional: true

#embeddable_idString, ...


# File 'app/models/simplec/embedded_image.rb', line 28

#embeddable_typeString?


# File 'app/models/simplec/embedded_image.rb', line 25

Instance Method Details

#urlString Also known as: asset_url

Dragonfly url for the asset.


40
41
42
43
44
# File 'app/models/simplec/embedded_image.rb', line 40

def url
  return unless self.asset
  return self.asset.url unless persisted?
  self.asset.url(ei: Base64.urlsafe_encode64(self.id.to_s))
end