compatibility
1 year ago
class-astra-sites-elementor-images.php
6 years ago
class-astra-sites-elementor-pages.php
2 years ago
class-astra-sites-error-handler.php
2 years ago
class-astra-sites-file-system.php
2 years ago
class-astra-sites-importer-log.php
2 years ago
class-astra-sites-importer.php
1 year ago
class-astra-sites-nps-notice.php
1 year ago
class-astra-sites-page.php
1 year ago
class-astra-sites-update.php
1 year ago
class-astra-sites-utils.php
2 years ago
class-astra-sites-white-label.php
2 years ago
class-astra-sites-wp-cli.php
2 years ago
class-astra-sites.php
1 year ago
functions.php
1 year ago
class-astra-sites-elementor-images.php
95 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Astra_Sites_Elementor_Images class |
| 4 | * |
| 5 | * This class is used to manage Pixabay Images. |
| 6 | * |
| 7 | * @package Astra Sites |
| 8 | * @since 2.0.0 |
| 9 | */ |
| 10 | |
| 11 | use Elementor\Utils; |
| 12 | |
| 13 | // If plugin - 'Elementor' not exist then return. |
| 14 | if ( class_exists( 'Astra_Sites_Elementor_Images' ) ) { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Astra_Sites_Elementor_Images |
| 20 | */ |
| 21 | class Astra_Sites_Elementor_Images { |
| 22 | |
| 23 | /** |
| 24 | * Instance of Astra_Sites |
| 25 | * |
| 26 | * @since 2.0.0 |
| 27 | * @var (Object) Astra_Sites |
| 28 | */ |
| 29 | private static $instance = null; |
| 30 | |
| 31 | /** |
| 32 | * Instance of Astra_Sites_Elementor_Images. |
| 33 | * |
| 34 | * @since 2.0.0 |
| 35 | * |
| 36 | * @return object Class object. |
| 37 | */ |
| 38 | public static function get_instance() { |
| 39 | if ( ! isset( self::$instance ) ) { |
| 40 | self::$instance = new self(); |
| 41 | } |
| 42 | |
| 43 | return self::$instance; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Import Image. |
| 48 | * |
| 49 | * @since 2.0.0 |
| 50 | * @param array $image Downloaded Image array. |
| 51 | */ |
| 52 | public function get_attachment_data( $image ) { |
| 53 | |
| 54 | if ( ! empty( $image ) ) { |
| 55 | return array( |
| 56 | 'content' => array( |
| 57 | array( |
| 58 | 'id' => \Elementor\Utils::generate_random_string(), |
| 59 | 'elType' => 'section', |
| 60 | 'settings' => array(), |
| 61 | 'isInner' => false, |
| 62 | 'elements' => array( |
| 63 | array( |
| 64 | 'id' => \Elementor\Utils::generate_random_string(), |
| 65 | 'elType' => 'column', |
| 66 | 'elements' => array( |
| 67 | array( |
| 68 | 'id' => \Elementor\Utils::generate_random_string(), |
| 69 | 'elType' => 'widget', |
| 70 | 'settings' => array( |
| 71 | 'image' => array( |
| 72 | 'url' => wp_get_attachment_url( $image ), |
| 73 | 'id' => $image, |
| 74 | ), |
| 75 | 'image_size' => 'full', |
| 76 | ), |
| 77 | 'widgetType' => 'image', |
| 78 | ), |
| 79 | ), |
| 80 | 'isInner' => false, |
| 81 | ), |
| 82 | ), |
| 83 | ), |
| 84 | ), |
| 85 | ); |
| 86 | } |
| 87 | return array(); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Kicking this off by calling 'get_instance()' method |
| 93 | */ |
| 94 | Astra_Sites_Elementor_Images::get_instance(); |
| 95 |