Fix #3984: Twitter: undefined method `first' for nil:NilClass.
Fix Sources::Strategies::Twitter#image_urls to return an empty array instead of nil when the tweet doesn't contain any images.
This commit is contained in:
@@ -41,15 +41,11 @@ module Sources::Strategies
|
||||
|
||||
def image_urls
|
||||
if url =~ /(#{ASSET}[^:]+)/
|
||||
return [$1 + ":orig" ]
|
||||
elsif api_response.blank?
|
||||
return [url]
|
||||
end
|
||||
|
||||
[url, referer_url].each do |x|
|
||||
if x =~ PAGE
|
||||
return service.image_urls(api_response)
|
||||
end
|
||||
[$1 + ":orig" ]
|
||||
elsif api_response.present?
|
||||
service.image_urls(api_response)
|
||||
else
|
||||
[url]
|
||||
end
|
||||
end
|
||||
memoize :image_urls
|
||||
|
||||
@@ -67,6 +67,8 @@ class TwitterService
|
||||
extract_urls_for_status(tweet)
|
||||
elsif tweet.urls.any?
|
||||
extract_urls_for_card(tweet)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% if params[:url] %>
|
||||
<% if ImageProxy.needs_proxy?(@source.image_url) %>
|
||||
<%= image_tag(image_proxy_uploads_path(:url => @source.image_url), :title => "Preview", :id => "image") %>
|
||||
<% else %>
|
||||
<% elsif @source.image_url.present? %>
|
||||
<%= image_tag(@source.image_url, :title => "Preview", :id => "image") %>
|
||||
<% end %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user