Add embed_url to preview cards (#5775)
This commit is contained in:
committed by
Eugen Rochko
parent
432761f375
commit
c083816c24
@ -101,7 +101,7 @@ export default class Card extends React.PureComponent {
|
||||
onClick={this.handlePhotoClick}
|
||||
role='button'
|
||||
tabIndex='0'
|
||||
src={card.get('url')}
|
||||
src={card.get('embed_url')}
|
||||
alt={card.get('title')}
|
||||
width={card.get('width')}
|
||||
height={card.get('height')}
|
||||
|
@ -21,6 +21,7 @@
|
||||
# height :integer default(0), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# embed_url :string default(""), not null
|
||||
#
|
||||
|
||||
class PreviewCard < ApplicationRecord
|
||||
|
@ -6,7 +6,7 @@ class REST::PreviewCardSerializer < ActiveModel::Serializer
|
||||
attributes :url, :title, :description, :type,
|
||||
:author_name, :author_url, :provider_name,
|
||||
:provider_url, :html, :width, :height,
|
||||
:image
|
||||
:image, :embed_url
|
||||
|
||||
def image
|
||||
object.image? ? full_asset_url(object.image.url(:original)) : nil
|
||||
|
@ -74,9 +74,6 @@ class FetchLinkCardService < BaseService
|
||||
|
||||
return false unless response.respond_to?(:type)
|
||||
|
||||
# The photo will change the URL. So, to avoid duplication of URLs, PreviewCard needs to be checked again.
|
||||
@card = PreviewCard.find_by(url: response.url) || @card if response.type == 'photo'
|
||||
|
||||
@card.type = response.type
|
||||
@card.title = response.respond_to?(:title) ? response.title : ''
|
||||
@card.author_name = response.respond_to?(:author_name) ? response.author_name : ''
|
||||
@ -90,9 +87,9 @@ class FetchLinkCardService < BaseService
|
||||
when 'link'
|
||||
@card.image = URI.parse(response.thumbnail_url) if response.respond_to?(:thumbnail_url)
|
||||
when 'photo'
|
||||
@card.url = response.url
|
||||
@card.width = response.width.presence || 0
|
||||
@card.height = response.height.presence || 0
|
||||
@card.embed_url = response.url
|
||||
@card.width = response.width.presence || 0
|
||||
@card.height = response.height.presence || 0
|
||||
when 'video'
|
||||
@card.width = response.width.presence || 0
|
||||
@card.height = response.height.presence || 0
|
||||
|
Reference in New Issue
Block a user