Render form template scripts.
Source
public function render_control_template_scripts() {
parent::render_control_template_scripts();
?>
<script type="text/html" id="tmpl-wp-media-widget-image-fields">
<# var elementIdPrefix = 'el' + String( Math.random() ) + '_'; #>
<# if ( data.url ) { #>
<p class="media-widget-image-link">
<label for="{{ elementIdPrefix }}linkUrl"><?php esc_html_e( 'Link to:' ); ?></label>
<input id="{{ elementIdPrefix }}linkUrl" type="text" class="widefat link" value="{{ data.link_url }}" placeholder="https://" pattern="((\w+:)?\/\/\w.*|\w+:(?!\/\/$)|\/|\?|#).*">
</p>
<# } #>
</script>
<script type="text/html" id="tmpl-wp-media-widget-image-preview">
<# if ( data.error && 'missing_attachment' === data.error ) { #>
<?php
wp_admin_notice(
$this->l10n['missing_attachment'],
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'notice-missing-attachment' ),
)
);
?>
<# } else if ( data.error ) { #>
<?php
wp_admin_notice(
__( 'Unable to preview media due to an unknown error.' ),
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt' ),
)
);
?>
<# } else if ( data.url ) { #>
<img class="attachment-thumb" src="{{ data.url }}" draggable="false" alt="{{ data.alt }}"
<# if ( ! data.alt && data.currentFilename ) { #>
aria-label="
<?php
echo esc_attr(
sprintf(
/* translators: %s: The image file name. */
__( 'The current image has no alternative text. The file name is: %s' ),
'{{ data.currentFilename }}'
)
);
?>
"
<# } #>
/>
<# } #>
</script>
<?php
}
Changelog
Version | Description |
---|---|
4.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.