'', 'url' => '', ]; } /** * Import media images. * * Used to import media control files from external sites while importing * Elementor template JSON file, and replacing the old data. * * @since 1.0.0 * * @param array $settings Control settings * * @return array Control settings */ public function onImport($settings) { if (empty($settings['url'])) { return $settings; } $settings = Plugin::$instance->templates_manager->getImportImagesInstance()->import($settings); if (!$settings) { $settings = [ 'id' => '', 'url' => Utils::getPlaceholderImageSrc(), ]; } return $settings; } public function onExport($settings) { if (!empty($settings['url'])) { $settings['url'] = Helper::getMediaLink($settings['url'], true); } return $settings; } /** * Render media control output in the editor. * * Used to generate the control HTML in the editor using Underscore JS * template. The variables for the class are available using `data` JS * object. * * @since 1.0.0 */ public function contentTemplate() { ?>
<# if ( 'image' === data.media_type || 'video' === data.media_type ) { #>
<# if( 'image' === data.media_type ) { #>
<# } else if( 'video' === data.media_type ) { #> <# } #>
<# if( 'image' === data.media_type ) { #>
<# if( data.seo ) { #>
<# if( !data.excludeLoading ) { #>
<# } #> <# } #> <# } else if( 'video' === data.media_type ) { #>
<# } #>
<# if( data.seo && !data.excludeLoading ) { #>
<# } #> <# } else { #>
<# } #> <# if ( data.description ) { #>
{{{ data.description }}}
<# } #>
true, 'media_type' => 'image', 'dynamic' => [ 'categories' => [TagsModule::IMAGE_CATEGORY], 'returnType' => 'object', ], ]; } /** * Get media control image title. * * Retrieve the `title` of the image selected by the media control. * * @since 1.0.0 * @static * * @param array $instance Media attachment * * @return string Image title */ public static function getImageTitle($instance) { return !empty($instance['title']) ? esc_attr($instance['title']) : ''; } /** * Get media control image alt. * * Retrieve the `alt` value of the image selected by the media control. * * @since 1.0.0 * @static * * @param array $instance Media attachment * * @return string Image alt */ public static function getImageAlt($instance) { return !empty($instance['alt']) ? esc_attr($instance['alt']) : ''; } }