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

Always use correct image meta dimensions #17258

Merged
merged 3 commits into from
Jun 26, 2017
Merged

Always use correct image meta dimensions #17258

merged 3 commits into from
Jun 26, 2017

Conversation

jfsoul
Copy link
Contributor

@jfsoul jfsoul commented Jun 23, 2017

What does this change?

The original motivation for this PR is to change the metadata in both structuredData/Image.scala and imageFigure.scala.html. The image dimensions are now for the same image as the url - whereas before they could have been different (in practice they never would be due to another bug, which will be fixed in another PR).

In doing this I wanted to simplify Profile.scala a bit so that the logic for whether we serve largest or best image for a profile is in one place (and callers of the class cannot pick and choose whether to follow that logic). That required a bit of renaming for clarity which is what the majority of changes here are.

What is the value of this and can you measure success?

We always provide correct image metadata dimensions and serve masters if using imgix and something else if not. The something else will be solidified in another PR, but it is intended to be the best crop from the grid for the provided profile size.

Does this affect other platforms - Amp, Apps, etc?

Yes, AMP

Screenshots

Tested in CODE?

Will do

@PRBuilds
Copy link

PRbuilds results:

Screenshots
desktop.pngtablet.pngmobile.pngwide.png

Exceptions (0)
thrown-exceptions.js

A11y validation (0)
a11y-report.txt

Apache Benchmark Load Testing
loadtesting.txt

--automated message

Json.obj(
"@type" -> "ImageObject",
"url" -> JsString(Item700.bestSrcFor(picture.images).getOrElse("")),
"height" -> asset.fold(0)(_.height),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically this isn't the true width even - it will just be Item700.width when imgix in use.

@paperboyo
Copy link
Contributor

paperboyo commented Jun 23, 2017

💎!

We always provide correct image metadata dimensions and serve masters if using imgix and something else if not.

Just a question, as nothing is ever clear for me from looking at the code... Does "always" means "whenever we do currently" (there are places when we should but don't now)? Or does it truly mean "always" now?

Almost totally unrelatedly, e.g. Lightbox and other places could gain from height-bound image sizes (instead of width-bound only). Maybe as slightly cheekily suggested by @rich-nguyen? Maybe by using the trick Oliver has found?

@@ -231,38 +222,25 @@ object ImgSrc extends Logging with implicits.Strings {
.mkString(", ")
}

def srcsetForProfile(profile: Profile, imageContainer: ImageMedia, hidpi: Boolean): String = {
if(ImageServerSwitch.isSwitchedOn) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you have to check for this anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has been moved into bestFor

Copy link
Contributor

@NataliaLKB NataliaLKB left a comment

Choose a reason for hiding this comment

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

Code looks good to me!

@jfsoul
Copy link
Contributor Author

jfsoul commented Jun 23, 2017

@paperboyo

Or does it truly mean "always" now?

Sadly not, only in the case of image metadata urls. And due to another issue, they were already masters anyway - but by accident, not design.

@jfsoul jfsoul merged commit fa01962 into master Jun 26, 2017
@jfsoul jfsoul deleted the jfs-img-meta branch June 26, 2017 10:21
@prout-bot
Copy link
Collaborator

Seen on PROD (merged by @jfsoul 22 minutes and 55 seconds ago)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants