-
Notifications
You must be signed in to change notification settings - Fork 0
/
filters.php
43 lines (35 loc) · 1.14 KB
/
filters.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* Kindling Image Forwarding - Filters
* @package Kindling_Image_Forwarding
*/
if (!function_exists('add_action')) {
return;
}
add_action('kindling_ready', function () {
add_filter('kindling_config_directories', function ($directories) {
$directories[] = __DIR__ . '/config';
return $directories;
});
/**
* Updates the attachment image src uri.
*/
add_filter('wp_get_attachment_image_src', function ($image, $attachment_id, $size, $icon) {
if (!$image) {
return $image;
}
$uri = isset($image[0]) ? $image[0] : '';
$image[0] = kindling_image_forwarding_replace_forward_uri($uri);
return $image;
}, 10, 4);
/**
* Updates the attachment image srcset uri.
*/
add_filter('wp_calculate_image_srcset', function ($sources, $size_array, $image_src, $image_meta, $attachment_id) {
return array_map(function ($source) {
$uri = isset($source['url']) ? $source['url'] : '';
$source['url'] = kindling_image_forwarding_replace_forward_uri($uri);
return $source;
}, $sources);
}, 10, 5);
});