diff --git a/README.md b/README.md
index 119fb3d030..bdad9c373d 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@
![](./public/avo-assets/logo-on-white.png)
-**Avo - Ruby on Rails admin panel framework**
+**Avo - Ruby on Rails Admin Panel Framework**
Avo is a very custom Admin Panel Framework, Content Management System, and Internal Tool Builder for Ruby on Rails that saves engineers and teams **months of development time**.
diff --git a/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb b/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb
index b1e4ca5da2..f2c9136309 100644
--- a/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb
+++ b/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb
@@ -2,7 +2,7 @@
<% if file.present? %>
<% if file.representable? && is_image? %>
- <%= image_tag helpers.main_app.url_for(file), class: "rounded-lg max-w-full self-start #{@extra_classes}" %>
+ <%= image_tag helpers.main_app.url_for(file), class: "rounded-lg max-w-full self-start #{@extra_classes}", loading: :lazy, width: file.metadata["width"], height: file.metadata["height"] %>
<% elsif is_audio? %>
<%= audio_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
<% elsif is_video? %>
diff --git a/app/components/avo/index/grid_cover_empty_state_component.html.erb b/app/components/avo/index/grid_cover_empty_state_component.html.erb
index 938f0af9fb..bd7e527a74 100644
--- a/app/components/avo/index/grid_cover_empty_state_component.html.erb
+++ b/app/components/avo/index/grid_cover_empty_state_component.html.erb
@@ -1,3 +1,3 @@
- <%= image_tag Avo.configuration.branding.placeholder, class: 'relative transform -translate-x-1/2 -translate-y-1/2 h-20 text-gray-400 inset-auto top-1/2 left-1/2' %>
+ <%= image_tag Avo.configuration.branding.placeholder, class: "relative transform -translate-x-1/2 -translate-y-1/2 h-20 text-gray-400 inset-auto top-1/2 left-1/2", loading: :lazy %>
diff --git a/app/components/avo/index/grid_item_component.rb b/app/components/avo/index/grid_item_component.rb
index 7fa42baa72..202b980ad5 100644
--- a/app/components/avo/index/grid_item_component.rb
+++ b/app/components/avo/index/grid_item_component.rb
@@ -48,7 +48,7 @@ def render_cover
def link_to_cover
classes = "absolute h-full w-full object-cover"
- link_to image_tag(@card[:cover_url], class: classes), resource_view_path, class: classes, title: @card[:title]
+ link_to image_tag(@card[:cover_url], class: classes), resource_view_path, class: classes, title: @card[:title], loading: :lazy, width: "640", height: "480"
end
def render_title
diff --git a/lib/avo/base_resource.rb b/lib/avo/base_resource.rb
index 47dbf23f64..87df2cafc8 100644
--- a/lib/avo/base_resource.rb
+++ b/lib/avo/base_resource.rb
@@ -150,11 +150,11 @@ def model_class(record_class: nil)
# With uncountable models route key appends an _index suffix (Fish->fish_index)
# Example: User->users, MediaItem->media_items, Fish->fish
def model_key
- model_class.model_name.plural
+ @model_key ||= model_class.model_name.plural
end
def class_name
- to_s.demodulize
+ @class_name ||= to_s.demodulize
end
def route_key
@@ -170,7 +170,7 @@ def translation_key
end
def name
- name_from_translation_key(count: 1, default: class_name.underscore.humanize)
+ @name ||= name_from_translation_key(count: 1, default: class_name.underscore.humanize)
end
alias_method :singular_name, :name
@@ -448,7 +448,6 @@ def authorization(user: nil)
def file_hash
content_to_be_hashed = ""
- file_name = self.class.underscore_name.tr(" ", "_")
resource_path = Rails.root.join("app", "avo", "resources", "#{file_name}.rb").to_s
if File.file? resource_path
content_to_be_hashed += File.read(resource_path)
@@ -463,6 +462,10 @@ def file_hash
Digest::MD5.hexdigest(content_to_be_hashed)
end
+ def file_name
+ @file_name ||= self.class.underscore_name.tr(" ", "_")
+ end
+
def cache_hash(parent_record)
result = [record, file_hash]
diff --git a/lib/avo/fields/base_field.rb b/lib/avo/fields/base_field.rb
index 675aaffa65..f52e457273 100644
--- a/lib/avo/fields/base_field.rb
+++ b/lib/avo/fields/base_field.rb
@@ -246,7 +246,7 @@ def record_errors
end
def type
- self.class.name.demodulize.to_s.underscore.gsub("_field", "")
+ @type ||= self.class.name.demodulize.to_s.underscore.gsub("_field", "")
end
def custom?