Skip to content

Commit

Permalink
Rename add_preload_link to add_image_preload_link
Browse files Browse the repository at this point in the history
Co-authored-by: felixarntz <flixos90@git.wordpress.org>
  • Loading branch information
westonruter and felixarntz committed Dec 2, 2024
1 parent 514c513 commit fbb6076
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class Image_Prioritizer_Background_Image_Styled_Tag_Visitor extends Image_
/**
* Tuples of URL Metric group and the common LCP element external background image.
*
* @since n.e.x.t
* @var array<array{OD_URL_Metric_Group, LcpElementExternalBackgroundImage}>
*/
private $group_common_lcp_element_external_background_images;
Expand Down Expand Up @@ -87,7 +88,7 @@ public function __invoke( OD_Tag_Visitor_Context $context ): bool {

// If this element is the LCP (for a breakpoint group), add a preload link for it.
foreach ( $context->url_metric_group_collection->get_groups_by_lcp_element( $xpath ) as $group ) {
$this->add_preload_link( $context->link_collection, $group, $background_image_url );
$this->add_image_preload_link( $context->link_collection, $group, $background_image_url );
}

$this->lazy_load_bg_images( $context );
Expand Down Expand Up @@ -169,7 +170,7 @@ private function maybe_preload_external_lcp_background_image( OD_Tag_Visitor_Con
&&
$processor->get_attribute( 'class' ) === $common['class'] // May be checking equality with null.
) {
$this->add_preload_link( $context->link_collection, $group, $common['url'] );
$this->add_image_preload_link( $context->link_collection, $group, $common['url'] );

// Now that the preload link has been added, eliminate the entry to stop looking for it while iterating over the rest of the document.
unset( $this->group_common_lcp_element_external_background_images[ $i ] );
Expand All @@ -186,7 +187,7 @@ private function maybe_preload_external_lcp_background_image( OD_Tag_Visitor_Con
* @param OD_URL_Metric_Group $group URL Metric group.
* @param non-empty-string $url Image URL.
*/
private function add_preload_link( OD_Link_Collection $link_collection, OD_URL_Metric_Group $group, string $url ): void {
private function add_image_preload_link( OD_Link_Collection $link_collection, OD_URL_Metric_Group $group, string $url ): void {
$link_collection->add_link(
array(
'rel' => 'preload',
Expand Down

0 comments on commit fbb6076

Please sign in to comment.