Last active
December 6, 2018 17:45
-
-
Save slimPickens/e42e361c6b853dc56af83fe69f989f7f to your computer and use it in GitHub Desktop.
Update cover image for video upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generateImages() { | |
let height, | |
aspectRatio = Config.aspectRatio.HEIGHT / Config.aspectRatio.WIDTH; | |
this.videos.forEach((video, index) => { | |
let currentVideoData = this.videos[index]; | |
if (this.moduleConfig.isPlaylist) { | |
currentVideoData = this.videos[index].videoMetadata; | |
} | |
const IPTCMetadata = currentVideoData.photoVideoMetadataIPTC, | |
FMGMetadata = currentVideoData.photoVideoMetadata_fmg; | |
// Set defaults | |
FMGMetadata['thumbnail'] = FMGMetadata['cover'] = IPTCMetadata.snapshotLinks && IPTCMetadata.snapshotLinks.length ? IPTCMetadata.snapshotLinks[0].link : ''; | |
if (this.moduleConfig.thumbnails && this.moduleConfig.thumbnails[IPTCMetadata.identifier]) { | |
FMGMetadata['thumbnail'] = this.moduleConfig.thumbnails[IPTCMetadata.identifier]; | |
} | |
if (this.moduleConfig.covers && this.moduleConfig.covers[IPTCMetadata.identifier]) { | |
FMGMetadata['cover'] = this.moduleConfig.covers[IPTCMetadata.identifier]; | |
} | |
if (this.pageLevelParams.coverOverride) { | |
// Get Image override from cloudinary | |
} else { | |
if (IPTCMetadata.cloudinaryLink && IPTCMetadata.cloudinaryLink.link) { | |
// get default image from cloudinary | |
height = Config.Cloudinary.Sizes.THUMBNAIL_WIDTH * aspectRatio; | |
FMGMetadata['thumbnail'] = Utils.formatCloudinaryImage( | |
IPTCMetadata.cloudinaryLink.link, Config.Cloudinary.Sizes.THUMBNAIL_WIDTH, parseInt(height) | |
); | |
height = Config.Cloudinary.Sizes.COVER_WIDTH * aspectRatio; | |
FMGMetadata['cover'] = Utils.formatCloudinaryImage( | |
IPTCMetadata.cloudinaryLink.link, Config.Cloudinary.Sizes.COVER_WIDTH, parseInt(height) | |
); | |
} | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment