| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\PropsResolver\Transformers; |
| 4 |
|
| 5 |
use Elementor\Modules\AtomicWidgets\PropsResolver\Props_Resolver_Context; |
| 6 |
use Elementor\Modules\AtomicWidgets\PropsResolver\Transformer_Base; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
class Image_Src_Transformer extends Transformer_Base { |
| 13 |
|
| 14 |
/** |
| 15 |
* This transformer (or rather this prop type) exists only to support dynamic images. |
| 16 |
* Currently, the dynamic tags that return images return it with id & url no matter |
| 17 |
* what, so we need to keep the same structure in the props. |
| 18 |
*/ |
| 19 |
public function transform( $value, Props_Resolver_Context $context ) { |
| 20 |
return [ |
| 21 |
'id' => isset( $value['id'] ) ? (int) $value['id'] : null, |
| 22 |
'url' => $value['url'] ?? null, |
| 23 |
]; |
| 24 |
} |
| 25 |
} |
| 26 |
|