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
Open
Show file tree
Hide file tree
Changes from all commits
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 .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"files.trimTrailingWhitespace": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"editor.acceptSuggestionOnEnter": "on"
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@quintype/seo",
"version": "1.42.2",
"version": "1.42.3-watermark-fiare-issue.4",
"description": "SEO Modules for Quintype",
"main": "dist/index.cjs.js",
"repository": "https://github.com/quintype/quintype-node-seo",
Expand Down
23 changes: 19 additions & 4 deletions src/image-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
const imageCdnSrc = publisherConfig.cdn_src;
const imageCdnUrl = publisherConfig.cdn_image || config["cdn-image"];
const fallbackSocialImage = get(seoConfig, ["fallbackSocialImage"]);
const watermarkImageS3Key = get(story, ["watermark", "social", "image-s3-key"], false);

if (!image) {
return [];
Expand All @@ -137,10 +138,16 @@ 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",
});

console.log(
"getWatermarkHeroImage LOGS 222:",
imageCdnSrc,
imageCdnUrl,
watermarkImageS3Key,
overlayWatermarkProps
);
const watermarkImageProps =
imageCdnSrc && imageCdnSrc.includes("gumlet")
? Object.assign({}, overlayWatermarkProps, {
Expand All @@ -160,7 +167,7 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
return image;
}
};

console.log("includesHost LOGS 333:", fallbackSocialImage, getFallbackImage());
return includesHost ? getFallbackImage() : `https://${imageCdnUrl}/${image.path(imageRatio, watermarkImageProps)}`;
};

Expand All @@ -173,7 +180,15 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
mode: "crop",
enlarge: true,
};
return isWatermarkDisabled ? getHeroImage(imageRatio, imageProp) : getWatermarkHeroImage(imageRatio, imageProp);
console.log(
"getImageContent LOGS 111:",
watermarkImageS3Key,
isWatermarkDisabled,
!watermarkImageS3Key || isWatermarkDisabled
);
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