Helper::get_thumbnail_url( string $size = 'small' )
Returns the thumbnail URL for the current video in loop
Parameters
- $size
-
(Optional)
Default value: 'small'
Return
(array|false|mixed|string|string[]|void)
Source
File: includes/libs/themes/helper.class.php
26 | public static function get_thumbnail_url( $size = 'small' ){ |
27 | $video = self::current_video_post(); |
28 | if ( ! $video ){ |
29 | return ; |
30 | } |
31 |
32 | $result = false; |
33 |
34 | $sizes = array_merge ( |
35 | /** |
36 | * Filter default sizes to allow additional sizes to be added. |
37 | * |
38 | * @since 2.0.15 |
39 | * |
40 | * @param array $sizes Registered thumbnail sizes stored as size_name => thumbnail ID in video thumbnails array. |
41 | * @param Video_Post $video The current video post being processed in loop. |
42 | */ |
43 | ( array ) apply_filters( 'vimeotheque\themes\thumbnail_image_sizes' , [], $video ), |
44 | [ |
45 | 'small' => 0, // 100x75 px |
46 | 'medium' => 1, // 200x150 px |
47 | 'large' => 2, // 295x166 px |
48 | 'original' => 3, // original image size ratio |
49 | 'hd_small' => 4, // 640x360 px |
50 | 'hd_medium' => 5, // 1280x720 px |
51 | 'hd_big' => 6 // 1920x1080 px |
52 | ] |
53 | ); |
54 |
55 | if ( ! array_key_exists ( $size , $sizes ) ){ |
56 | $size = 'small' ; |
57 | } |
58 |
59 | $thumbnails = array_values ( $video ->thumbnails ); |
60 |
61 | if ( isset( $thumbnails [ $sizes [ $size ] ] ) ){ |
62 | $result = $thumbnails [ $sizes [ $size ] ]; |
63 | if ( is_ssl() ){ |
65 | } |
66 | } |
67 |
68 | if ( 'original' === $size ){ |
69 | $result = remove_query_arg( 'r' , $result ); |
70 | } |
71 |
72 | return $result ; |
73 | } |
Changelog
Version | Description |
---|---|
2.0.14 | Introduced. |