PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.8
Elementor Website Builder – more than just a page builder v3.25.8
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 / image-sizes.php

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

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