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

Perf images #319

Merged
merged 16 commits into from
Jan 13, 2021
Merged

Perf images #319

merged 16 commits into from
Jan 13, 2021

Conversation

ags1773
Copy link
Contributor

@ags1773 ags1773 commented Dec 28, 2020

@@ -629,9 +629,7 @@ export const ampConfig: AMPConfig = {
"gtm-id": "GTM-XXXXXX",
"google-client-id-api": false,
"invalid-elements-strategy": "redirect-to-web-version",
"google-analytics-tracking-id": "UA-ABCDEFG",
"fallback-image-url":
"https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/300px-Wikipedia-logo-v2.svg.png"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past we had thought of passing fallback-image-url via ampConfig using which publishers could pass an absolute url of a fallback image of their choice if they don't want to use the fallback image provided by ampLib (we didn't have a featureConfig back then). Removing it since we never added it to ampConfig, and I don't really see any publisher who would want this feature.

switch (layout) {
case "fixed-height":
value.width = "";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found out during testing that images with layout = "fixed-height" should not have prop width.. it gives a validation error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed variable name from value to imgAttrs as it's more descriptive

break;
case "fixed" || "intrinsic":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case "fixed" || "intrinsic" is invalid. Changed to

case "fixed":
case "intrinsic":

Found this on adding more tests

config: Config;
slug: string;
slug: string | null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image metadata and slug can be null. Made correction

slug,
aspectRatio,
alt,
layout = "responsive",
opts = {},
srcSetOpts = {},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opts -> used to add query params on src
srcSetOpts -> used to add query params on srcset

This is needed because hero-image needs to add {w: 1200, enlarge: true} only on src, not on srcset

);
expect(wrapper.find("amp-img").exists()).toBeTruthy();
expect(wrapper.find(`amp-img`).prop("srcset")).toBeUndefined();
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipSrcset isn't being used anywhere, can remove if needed. Was planning to use it for PublisherLogoHeader component but decided not to use <Image> component in PublisherLogoHeader

@ags1773 ags1773 requested a review from himani39 December 28, 2020 14:54
return { src, srcset };
};

export const focusedImagePath = ({ opts, slug, metadata, aspectRatio, cdnImage, width }: FocusedImagePathTypes) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this being used at any other place? If not, no need to export.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

skipSrcset
}: GetImgSrcAndSrcsetTypes) => {
const src = focusedImagePath({ opts, slug, metadata, aspectRatio, cdnImage });
if (skipSrcset) return { src, srcset: null };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When can we need to skip srcSet? Wondering will it ever be true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#319 (comment)
Removing skipSrcset


export const CoverPageBase = ({ story, config }: CoverPageProps) => {
const heroImgSrc = story["hero-image-s3-key"];
const heroImgMetadata = story["hero-image-metadata"];
const altText = story["hero-image-caption"] || story["hero-image-attribution"] || "";
const authorNames = getAuthorNames(story.authors);
const imageAnimationProps = getImageAnimationProps(config);
const imgOpts = isGumlet(config) ? { format: "auto" } : {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving the logic of checking isGumlet true and adding format auto to opts and srcSetOpts to image component itself. Currently its duplicated across all the places.
This is unless you can think of any scenario when we would not want to not add format auto for a gumlet image.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, can move format: "auto" inside image

@himani39
Copy link
Contributor

Visual story: although the score is lower than prod, properly size images is gone

@ags1773 Can we get the comparison on vikatan-gamma before and after the changes?

@ags1773
Copy link
Contributor Author

ags1773 commented Jan 6, 2021

Visual story: although the score is lower than prod, properly size images is gone

@ags1773 Can we get the comparison on vikatan-gamma before and after the changes?

Screenshot 2021-01-06 at 3 11 05 PM
Visual Story

@ags1773 ags1773 mentioned this pull request Jan 6, 2021
@ags1773 ags1773 merged commit 4b72026 into master Jan 13, 2021
@delete-merged-branch delete-merged-branch bot deleted the perf-images branch January 13, 2021 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants