thumbnail fixes and tags
This commit is contained in:
parent
8940c3c63a
commit
43acff783e
|
@ -25,7 +25,7 @@ class VideoProsController < ApplicationController
|
|||
end
|
||||
@video_image.view_count += 1
|
||||
@video_image.inc_count
|
||||
render :layout=>false
|
||||
render :layout=>false
|
||||
end
|
||||
def index
|
||||
params = OrbitHelper.params
|
||||
|
@ -200,7 +200,7 @@ class VideoProsController < ApplicationController
|
|||
}
|
||||
}
|
||||
else
|
||||
video_images = VideoImage.where(:title.nin => ["",nil]).can_display_and_sorted.filter_by_widget_categories.to_a
|
||||
video_images = VideoImage.where(:title.nin => ["",nil]).can_display_and_sorted.filter_by_widget_categories.filter_by_tags(OrbitHelper.widget_tags).to_a
|
||||
custom_data_field = subpart.custom_data_field || {}
|
||||
@video_pro_setting = VideoProSetting.first
|
||||
videos = get_videos(video_images, OrbitHelper.widget_item_url(''), custom_data_field)
|
||||
|
|
|
@ -72,34 +72,35 @@ class VideoImage
|
|||
self.youtube_id = v
|
||||
end
|
||||
end
|
||||
if self.is_youtube
|
||||
begin
|
||||
youtube_img_url = "https:"+self.youtube_thumb
|
||||
uri = URI.parse(youtube_img_url)
|
||||
req = Net::HTTP::Get.new(uri.path)
|
||||
res = Net::HTTP.start( uri.host, uri.port,
|
||||
:use_ssl => (uri.scheme == 'https'),
|
||||
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
|
||||
https.request(req)
|
||||
end
|
||||
snapshot_content = res.body rescue nil #Net::HTTP.get_response(URI.parse(youtube_img_url)).body rescue nil
|
||||
if snapshot_content
|
||||
self[:video_snapshot] = '0.jpg'
|
||||
snapshot_file_path = self.video_snapshot.file.path
|
||||
FileUtils.mkdir_p(File.dirname(snapshot_file_path))
|
||||
File.open(snapshot_file_path, 'wb'){|f| f.write(snapshot_content)}
|
||||
image = MiniMagick::Image.open(snapshot_file_path)
|
||||
self.scale = (1.0 * image[:height] / image[:width] * 100).round(2)
|
||||
else
|
||||
puts "cannot read #{youtube_img_url}"
|
||||
end
|
||||
rescue => e
|
||||
puts e.to_s
|
||||
self.scale = nil
|
||||
end
|
||||
else
|
||||
self.scale = nil
|
||||
end
|
||||
# if self.is_youtube
|
||||
# begin
|
||||
# youtube_img_url = "https:"+self.youtube_thumb
|
||||
# self.remote_file_url = youtube_img_url
|
||||
# uri = URI.parse(youtube_img_url)
|
||||
# req = Net::HTTP::Get.new(uri.path)
|
||||
# res = Net::HTTP.start( uri.host, uri.port,
|
||||
# :use_ssl => (uri.scheme == 'https'),
|
||||
# :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
|
||||
# https.request(req)
|
||||
# end
|
||||
# snapshot_content = res.body rescue nil #Net::HTTP.get_response(URI.parse(youtube_img_url)).body rescue nil
|
||||
# if snapshot_content
|
||||
# self[:video_snapshot] = '0.jpg'
|
||||
# snapshot_file_path = self.video_snapshot.file.path
|
||||
# FileUtils.mkdir_p(File.dirname(snapshot_file_path))
|
||||
# File.open(snapshot_file_path, 'wb'){|f| f.write(snapshot_content)}
|
||||
# image = MiniMagick::Image.open(snapshot_file_path)
|
||||
# self.scale = (1.0 * image[:height] / image[:width] * 100).round(2)
|
||||
# else
|
||||
# puts "cannot read #{youtube_img_url}"
|
||||
# end
|
||||
# rescue => e
|
||||
# puts e.to_s
|
||||
# self.scale = nil
|
||||
# end
|
||||
# else
|
||||
# self.scale = nil
|
||||
# end
|
||||
else
|
||||
self.youtube_id = nil
|
||||
image = MiniMagick::Image.open(self.video_snapshot.file.path) rescue nil
|
||||
|
@ -128,6 +129,13 @@ class VideoImage
|
|||
self.generate_video_snapshot
|
||||
end
|
||||
end
|
||||
if self.is_youtube
|
||||
Thread.new do
|
||||
youtube_img_url = "https:"+self.youtube_thumb
|
||||
self.remote_file_url = youtube_img_url
|
||||
self.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
def inc_count
|
||||
|
|
|
@ -61,8 +61,19 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="exchange_item_3" style="display:none">
|
||||
<!-- Images Upload -->
|
||||
<div id="exchange_item_3" style="display:none;">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="exchange_item_1" style="display:none">
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("video_pro.youtube") %></label>
|
||||
<div class="controls">
|
||||
<div><%= 'ex. https://www.youtube.com/watch?v=UHF2e3lyPVU' %></div>
|
||||
<%= f.text_field :youtube, placeholder: t("video_pro.youtube"), class: 'input-block-level' %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Images Upload -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:image) %></label>
|
||||
<div class="controls">
|
||||
|
@ -71,7 +82,7 @@
|
|||
<% if @video_image.file.file %>
|
||||
<%= image_tag @video_image.file.url %>
|
||||
<% else %>
|
||||
<img src="https://via.placeholder.com/200x80/EFEFEF/AAAAAA" />
|
||||
<img src="https://placehold.co/200X200" />
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||
|
@ -91,16 +102,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="exchange_item_1" style="display:none">
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("video_pro.youtube") %></label>
|
||||
<div class="controls">
|
||||
<div><%= 'ex. https://www.youtube.com/watch?v=UHF2e3lyPVU' %></div>
|
||||
<%= f.text_field :youtube, placeholder: t("video_pro.youtube"), class: 'input-block-level' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="exchange_item_2" style="display:none">
|
||||
<!-- Video Upload -->
|
||||
<div class="control-group">
|
||||
|
@ -133,7 +134,7 @@
|
|||
<% if @video_image.video_snapshot.file %>
|
||||
<%= image_tag @video_image.video_snapshot.url %>
|
||||
<% else %>
|
||||
<img src="https://via.placeholder.com/200x80/EFEFEF/AAAAAA" />
|
||||
<img src="https://placehold.co/200X200" />
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||
|
|
Loading…
Reference in New Issue