-
Notifications
You must be signed in to change notification settings - Fork 101
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
Add group collection helper methods to get the first/last groups #1602
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
$widest_group = array_reduce( | ||
iterator_to_array( $context->url_metric_group_collection ), | ||
static function ( $carry, OD_URL_Metric_Group $group ) { | ||
return ( null === $carry || $group->get_minimum_viewport_width() > $carry->get_minimum_viewport_width() ) ? $group : $carry; | ||
} | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This iteration is now eliminated for every video[poster]
in the document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @westonruter, LGTM!
In #1596 we need to exclusively look at the desktop group of URL metrics to determine the widest possible width for a given element, excluding widths from narrower viewport groups (e.g. mobile) since they could result in an image size being chosen which would look bad on desktop. This adds a
OD_URL_Metric_Group_Collection::get_last_group()
helper method to facilitate this. It also adds aOD_URL_Metric_Group_Collection::get_first_group()
for parity.