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

fiare's Watermark issue on passing overlay image attribute as false #549

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Refactor. watermark Fiare issue
  • Loading branch information
Veena2 authored and Veena2 committed Sep 29, 2023
commit d14d63a7f745a7fd40eedf82277db7ecae4221e7
6 changes: 4 additions & 2 deletions src/image-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {

const getWatermarkHeroImage = (imageRatio, imageProp) => {
const overlayWatermarkProps = Object.assign({}, imageProp, {
overlay: getWatermarkImage(story, imageCdnSrc, imageCdnUrl),
overlay: getWatermarkImage(imageCdnSrc, imageCdnUrl, watermarkImageS3Key),
overlay_position: "bottom",
});

Expand Down Expand Up @@ -174,7 +174,9 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
mode: "crop",
enlarge: true,
};
return ( !watermarkImageS3Key || isWatermarkDisabled ) ? getHeroImage(imageRatio, imageProp) : getWatermarkHeroImage(imageRatio, imageProp);
return !watermarkImageS3Key || isWatermarkDisabled
? getHeroImage(imageRatio, imageProp)
: getWatermarkHeroImage(imageRatio, imageProp);
};

if (seoConfig.enableTwitterCards) {
Expand Down
5 changes: 2 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { format, utcToZonedTime } from "date-fns-tz";
import { entries, get } from "lodash";
import { entries } from "lodash";
import { URL, URLSearchParams } from "url";

export function objectToTags(object) {
Expand Down Expand Up @@ -33,8 +33,7 @@ export function isStoryPublic(story) {
return story.access === undefined || story.access === null || story.access === "public";
}

export function getWatermarkImage(story, cdnSrc, cdnURL) {
const watermarkImageS3Key = get(story, ["watermark", "social", "image-s3-key"], false);
export function getWatermarkImage(cdnSrc, cdnURL, watermarkImageS3Key) {
if (cdnSrc && cdnSrc.includes("gumlet") && watermarkImageS3Key) {
return `https://${cdnURL}/${watermarkImageS3Key}`;
}
Expand Down