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 8 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.3",
"description": "SEO Modules for Quintype",
"main": "dist/index.cjs.js",
"repository": "https://github.com/quintype/quintype-node-seo",
Expand Down
7 changes: 5 additions & 2 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,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 @@ -173,7 +174,9 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
mode: "crop",
enlarge: true,
};
return 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