Skip to content

Commit ba0bc2b

Browse files
Merge pull request #1023 from tdatu/dns-prefetch
add ability to remove dns-prefetch or preconnect link tags
2 parents 931893b + d374ae2 commit ba0bc2b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

php/class-delivery.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,17 @@ protected function setup_hooks() {
725725
*/
726726
public function dns_prefetch( $urls, $relation_type ) {
727727

728-
if ( 'dns-prefetch' === $relation_type || 'preconnect' === $relation_type ) {
729-
$urls[] = $this->media->base_url;
730-
}
728+
/**
729+
* Filter to provide option to omit prefetch.
730+
*
731+
* @hook cloudinary_dns_prefetch_types
732+
*
733+
*/
734+
$resource_hints = apply_filters( 'cloudinary_dns_prefetch_types', array ( 'dns-prefetch', 'preconnect' ) );
735+
736+
if ( in_array( $relation_type, $resource_hints, true ) {
737+
$urls[] = $this->media->base_url;
738+
}
731739

732740
return $urls;
733741
}

0 commit comments

Comments
 (0)