Skip to content

Commit a49b6bb

Browse files
authored
Update workshop_default image and set bookmark default image (#308)
* Update workshop_default image and set bookmark default image * Remove merge text
1 parent 9ab44e9 commit a49b6bb

File tree

8 files changed

+16
-11
lines changed

8 files changed

+16
-11
lines changed
957 KB
Loading

app/models/bookmark.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,14 @@ def self.user_name(user_name)
133133
name: "%#{user_name_sanitized}%"
134134
)
135135
end
136+
137+
def bookmarkable_image_url(fallback: 'missing.png')
138+
if bookmarkable.respond_to?(:images) && bookmarkable.images.first&.file&.attached?
139+
Rails.application.routes.url_helpers.rails_blob_path(bookmarkable.images.first.file, only_path: true)
140+
elsif bookmarkable_type == "Workshop"
141+
ActionController::Base.helpers.asset_path("workshop_default.jpg")
142+
else
143+
ActionController::Base.helpers.asset_path(fallback)
144+
end
145+
end
136146
end

app/models/resource.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def main_image_url
8484
if main_image&.file&.attached?
8585
Rails.application.routes.url_helpers.url_for(main_image.file)
8686
else
87-
ActionController::Base.helpers.asset_path("workshop_default.png")
87+
ActionController::Base.helpers.asset_path("theme_default.png")
8888
end
8989
end
9090

app/models/workshop.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def main_image_url
177177
if images&.first&.file&.attached?
178178
Rails.application.routes.url_helpers.url_for(images.first.file)
179179
else
180-
ActionController::Base.helpers.asset_path("workshop_default.png")
180+
ActionController::Base.helpers.asset_path("workshop_default.jpg")
181181
end
182182
end
183183

app/views/bookmarks/_flex.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<%= link_to workshop_path(workshop) do %>
8787
<img
8888
class="object-cover w-full h-full"
89-
src="<%= workshop.images.last&.file&.url || asset_path('workshop_default.png') %>"
89+
src="<%= workshop.images.last&.file&.url || asset_path('workshop_default.jpg') %>"
9090
>
9191
<% end %>
9292
</div>

app/views/bookmarks/_personal_row.html.erb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,8 @@
4545
<!-- Image -->
4646
<div class="w-12 h-8 bg-gray-100 rounded overflow-hidden">
4747
<%= link_to polymorphic_path(bookmarkable) do %>
48-
<% if bookmarkable.respond_to?(:images) %>
49-
<img
50-
class="object-cover w-full h-full"
51-
src="<%= bookmarkable.images.last&.file&.url || asset_path('workshop_default.png') %>"
52-
alt="<%= bookmarkable.object.class.name %> image"
53-
>
54-
<% end %>
48+
<%= image_tag(bookmark.bookmarkable_image_url, class: "object-cover w-full h-full",
49+
alt: "#{ bookmarkable.object.class.name } image") %>
5550
<% end %>
5651
</div>
5752

config/initializers/assets.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
Rails.application.config.assets.precompile += %w[awbw/foundation_emails-20250913.css]
1616

1717
Rails.application.config.assets.precompile += %w[
18-
workshop_default.png
18+
workshop_default.jpg
1919
]

0 commit comments

Comments
 (0)