This commit is contained in:
BoHung Chiu 2023-07-04 14:30:03 +08:00
parent c5add605f9
commit cfe0fd9c5a
2 changed files with 55 additions and 37 deletions

View File

@ -225,15 +225,21 @@
<% banner.ad_images.can_display.desc(:created_at).each do |image| %> <% banner.ad_images.can_display.desc(:created_at).each do |image| %>
<% if image.exchange_item == '1' %> <% if image.exchange_item == '1' %>
<div class="slide-img" style=" background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"></div> <div class="slide-img" style=" background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"></div>
<% elsif image.video_snapshot %> <% elsif image.video_snapshot.present? %>
<div class="slide-img" style=" background: url('<%= image.video_snapshot %>'); background-size: cover; background-position: center;"></div> <div class="slide-img" style=" background: url('<%= image.video_snapshot %>'); background-size: cover; background-position: center;"></div>
<% elsif image.exchange_item == '2' %> <% elsif image.exchange_item == '2' %>
<div class="slide-img" style=" background: url('<%= image.youtube_thumb %>'); background-size: cover; background-position: center;"></div> <div class="slide-img" style=" background: url('<%= image.youtube_thumb %>'); background-size: cover; background-position: center;"></div>
<% end %> <% end %>
<% end %> <% end %>
<% else %> <% else %>
<div class="slide-img" style="background: url('/annc_url?url=http://placehold.it/<%= banner.width %>x<%= banner.height %>/888&text=A'); background-size: cover; background-position: center;"></div> <%
<div class="slide-img" style="background: url('/annc_url?url=http://placehold.it/<%= banner.width %>x<%= banner.height %>/666&text=B'); background-size: cover; background-position: center;"></div> width = banner.width
height = banner.height
width = 200 if width.blank?
height = 80 if height.blank?
%>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= width %>x<%= height %>/888&text=A'); background-size: cover; background-position: center;"></div>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= width %>x<%= height %>/666&text=B'); background-size: cover; background-position: center;"></div>
<% end %> <% end %>
</div> </div>

View File

@ -28,11 +28,23 @@
> >
<% if !banner.ad_images.can_display.blank? %> <% if !banner.ad_images.can_display.blank? %>
<% banner.ad_images.can_display.desc(:created_at).each do |image| %> <% banner.ad_images.can_display.desc(:created_at).each do |image| %>
<div class="slide-img" style=" background: url('<%= image.exchange_item == "1" ? image.file.thumb.url : image.youtube_thumb %>'); background-size: cover; background-position: center;"></div> <% if image.exchange_item == '1' %>
<div class="slide-img" style=" background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"></div>
<% elsif image.video_snapshot.present? %>
<div class="slide-img" style=" background: url('<%= image.video_snapshot %>'); background-size: cover; background-position: center;"></div>
<% elsif image.exchange_item == '2' %>
<div class="slide-img" style=" background: url('<%= image.youtube_thumb %>'); background-size: cover; background-position: center;"></div>
<% end %>
<% end %> <% end %>
<% else %> <% else %>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= banner.width %>x<%= banner.height %>/888&text=A'); background-size: cover; background-position: center;"></div> <%
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= banner.width %>x<%= banner.height %>/666&text=B'); background-size: cover; background-position: center;"></div> width = banner.width
height = banner.height
width = 200 if width.blank?
height = 80 if height.blank?
%>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= width %>x<%= height %>/888&text=A'); background-size: cover; background-position: center;"></div>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= width %>x<%= height %>/666&text=B'); background-size: cover; background-position: center;"></div>
<% end %> <% end %>
</div> </div>