PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.3
Elementor Website Builder – more than just a page builder v3.34.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / atomic-widgets / utils / image / image-sizes.php

image-sizes.php in Elementor Website Builder – more than just a page builder 3.34.3, at modules/atomic-widgets/utils/image/image-sizes.php

68 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicWidgets\Utils\Image;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 class Image_Sizes {
10 const DEFAULT_SIZE = 'large';
11
12 public static function get_keys() {
13 return array_map(
14 fn( $size ) => $size['value'],
15 static::get_all()
16 );
17 }
18
19 public static function get_all(): array {
20 $wp_image_sizes = static::get_wp_image_sizes();
21
22 $image_sizes = [];
23
24 foreach ( $wp_image_sizes as $size_key => $size_attributes ) {
25
26 $control_title = ucwords( str_replace( '_', ' ', $size_key ) );
27
28 if ( is_array( $size_attributes ) ) {
29 $control_title .= sprintf( ' - %d*%d', $size_attributes['width'], $size_attributes['height'] );
30 }
31
32 $image_sizes[] = [
33 'label' => $control_title,
34 'value' => $size_key,
35 ];
36 }
37
38 $image_sizes[] = [
39 'label' => esc_html__( 'Full', 'elementor' ),
40 'value' => 'full',
41 ];
42
43 return $image_sizes;
44 }
45
46 private static function get_wp_image_sizes() {
47 $default_image_sizes = get_intermediate_image_sizes();
48 $additional_sizes = wp_get_additional_image_sizes();
49
50 $image_sizes = [];
51
52 foreach ( $default_image_sizes as $size ) {
53 $image_sizes[ $size ] = [
54 'width' => (int) get_option( $size . '_size_w' ),
55 'height' => (int) get_option( $size . '_size_h' ),
56 'crop' => (bool) get_option( $size . '_crop' ),
57 ];
58 }
59
60 if ( $additional_sizes ) {
61 $image_sizes = array_merge( $image_sizes, $additional_sizes );
62 }
63
64 // /** This filter is documented in wp-admin/includes/media.php */
65 return apply_filters( 'image_size_names_choose', $image_sizes );
66 }
67 }
68