Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses HD thumbnail for opengraph when available. #696

Merged
merged 3 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/components/VideoDebate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { resetVideoDebate } from '../../state/video_debate/actions'
import { ColumnVideo } from './ColumnVideo'
import { ColumnDebate } from './ColumnDebate'
import { videoURL, toAbsoluteURL } from '../../lib/cf_routes'
import { getHDThumbnailUrl } from '../../lib/video_utils'

@connect(
(state) => ({
Expand Down Expand Up @@ -55,7 +56,7 @@ export class VideoDebate extends React.PureComponent {

renderMeta(video) {
const title = `Vérification complète de : ${video.title}`
const image = video.thumbnail
const image = getHDThumbnailUrl(video)
const description = `${video.title} vérifiée citation par citation par la communauté CaptainFact`
return (
<Helmet>
Expand Down
11 changes: 11 additions & 0 deletions app/lib/video_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ export const getTimecode = (videoPlayer, video, baseTimecode) => {
return getTimecodesOffset(video, videoPlayer) + baseTimecode
}

/**
* Returns HD thumbnail URL if any, otherwise returns the default thumbnail URL.
*/
export const getHDThumbnailUrl = (video) => {
if (video.youtube_id) {
return `https://img.youtube.com/vi/${video.youtube_id}/hqdefault.jpg`
}

return video.thumbnail
}

export const THUMBNAILS_SIZES = {
MEDIUM: 'MEDIUM',
LARGE: 'LARGE',
Expand Down