| 1 |
<?php |
| 2 |
namespace YayMail\Elements; |
| 3 |
|
| 4 |
use YayMail\Abstracts\BaseElement; |
| 5 |
use YayMail\Utils\SingletonTrait; |
| 6 |
/** |
| 7 |
* Images Elements |
| 8 |
*/ |
| 9 |
class Image extends BaseElement { |
| 10 |
|
| 11 |
use SingletonTrait; |
| 12 |
|
| 13 |
protected static $type = 'image'; |
| 14 |
|
| 15 |
public $available_email_ids = [ YAYMAIL_ALL_EMAILS ]; |
| 16 |
|
| 17 |
public static function get_data( $attributes = [] ) { |
| 18 |
$default_src = esc_url( YAYMAIL_PLUGIN_URL . 'assets/images/default-photo.png' ); |
| 19 |
self::$icon = '<svg viewBox="64 64 896 896" data-icon="picture" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><path d="M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 632H136v-39.9l138.5-164.3 150.1 178L658.1 489 888 761.6V792zm0-129.8L664.2 396.8c-3.2-3.8-9-3.8-12.2 0L424.6 666.4l-144-170.7c-3.2-3.8-9-3.8-12.2 0L136 652.7V232h752v430.2zM304 456a88 88 0 1 0 0-176 88 88 0 0 0 0 176zm0-116c15.5 0 28 12.5 28 28s-12.5 28-28 28-28-12.5-28-28 12.5-28 28-28z"></path></svg>'; |
| 20 |
|
| 21 |
return [ |
| 22 |
'id' => uniqid(), |
| 23 |
'type' => self::$type, |
| 24 |
'name' => __( 'Image', 'yaymail' ), |
| 25 |
'icon' => self::$icon, |
| 26 |
'group' => 'basic', |
| 27 |
'available' => true, |
| 28 |
'position' => 30, |
| 29 |
'data' => [ |
| 30 |
'container_group_definition' => [ |
| 31 |
'component' => 'GroupDefinition', |
| 32 |
'title' => __( 'Container settings', 'yaymail' ), |
| 33 |
'description' => __( 'Handle container layout settings', 'yaymail' ), |
| 34 |
], |
| 35 |
'padding' => [ |
| 36 |
'value_path' => 'padding', |
| 37 |
'component' => 'Spacing', |
| 38 |
'title' => __( 'Padding', 'yaymail' ), |
| 39 |
'default_value' => isset( $attributes['padding'] ) ? $attributes['padding'] : [ |
| 40 |
'top' => '15', |
| 41 |
'right' => '50', |
| 42 |
'bottom' => '15', |
| 43 |
'left' => '50', |
| 44 |
], |
| 45 |
'type' => 'style', |
| 46 |
], |
| 47 |
'background_color' => [ |
| 48 |
'value_path' => 'background_color', |
| 49 |
'component' => 'Color', |
| 50 |
'title' => __( 'Background color', 'yaymail' ), |
| 51 |
'default_value' => isset( $attributes['background_color'] ) ? $attributes['background_color'] : '#fff', |
| 52 |
'type' => 'style', |
| 53 |
], |
| 54 |
'image_breaker' => [ |
| 55 |
'component' => 'LineBreaker', |
| 56 |
], |
| 57 |
'image_group_definition' => [ |
| 58 |
'component' => 'GroupDefinition', |
| 59 |
'title' => __( 'Image settings', 'yaymail' ), |
| 60 |
'description' => __( 'Handle image settings', 'yaymail' ), |
| 61 |
], |
| 62 |
'src' => [ |
| 63 |
'value_path' => 'src', |
| 64 |
'component' => 'Media', |
| 65 |
'title' => __( 'Source image', 'yaymail' ), |
| 66 |
'default_value' => isset( $attributes['src'] ) ? $attributes['src'] : $default_src, |
| 67 |
'type' => 'content', |
| 68 |
], |
| 69 |
'align' => [ |
| 70 |
'value_path' => 'align', |
| 71 |
'component' => 'Align', |
| 72 |
'title' => __( 'Image position', 'yaymail' ), |
| 73 |
'default_value' => isset( $attributes['align'] ) ? $attributes['align'] : 'center', |
| 74 |
'type' => 'style', |
| 75 |
], |
| 76 |
'full_width' => [ |
| 77 |
'value_path' => 'full_width', |
| 78 |
'component' => 'Switcher', |
| 79 |
'title' => __( 'Full width', 'yaymail' ), |
| 80 |
'default_value' => isset( $attributes['full_width'] ) ? $attributes['full_width'] : false, |
| 81 |
'type' => 'style', |
| 82 |
], |
| 83 |
'width' => [ |
| 84 |
'value_path' => 'width', |
| 85 |
'component' => 'Dimension', |
| 86 |
'title' => __( 'Width', 'yaymail' ), |
| 87 |
'default_value' => isset( $attributes['width'] ) ? $attributes['width'] : '252', |
| 88 |
'type' => 'style', |
| 89 |
'conditions' => [ |
| 90 |
[ |
| 91 |
'comparison' => '!=', |
| 92 |
'value' => true, |
| 93 |
'attribute' => 'full_width', |
| 94 |
], |
| 95 |
], |
| 96 |
], |
| 97 |
'url' => [ |
| 98 |
'value_path' => 'url', |
| 99 |
'component' => 'TextInput', |
| 100 |
'title' => __( 'Open link', 'yaymail' ), |
| 101 |
'default_value' => isset( $attributes['url'] ) ? $attributes['url'] : '#', |
| 102 |
'type' => 'content', |
| 103 |
], |
| 104 |
'alt' => ElementsHelper::get_text_input( |
| 105 |
$attributes, |
| 106 |
[ |
| 107 |
'value_path' => 'alt', |
| 108 |
'title' => __( 'ALT text', 'yaymail' ), |
| 109 |
'default_value' => '', |
| 110 |
] |
| 111 |
), |
| 112 |
], |
| 113 |
]; |
| 114 |
} |
| 115 |
} |
| 116 |
|