mainSetting->getChildValue('attachmentId', 0); if ( !empty($attachmentId) ) { //Verify that the attachment exists. $attachmentUrl = wp_get_attachment_image_url($attachmentId, 'full'); if ( !$attachmentUrl ) { $attachmentId = 0; } } $externalUrlsAllowed = $this->mainSetting->areExternalUrlsAllowed(); $externalUrl = $this->mainSetting->getChildValue('externalUrl', ''); $imageUrl = $this->mainSetting->getImageUrl(); $canSelectAttachment = $this->isEnabled() && current_user_can('upload_files'); $canSelectExternalUrl = $this->isEnabled() && $externalUrlsAllowed; echo HtmlHelper::tag('div', [ 'class' => 'ame-image-selector-v2', 'data-bind' => 'ameObservableChangeEvents: ' . $this->getKoObservableExpression($imageUrl), ]); ?>

Sorry, this feature is not available in the demo because image upload is disabled.

%s', empty($imageUrl) ? '' : 'display: none;', esc_attr($noImageText), esc_attr('Loading...'), esc_html($noImageText) ); if ( !empty($imageUrl) ) { /** @noinspection HtmlUnknownTarget */ printf('Image preview', esc_attr($imageUrl)); } ?>
'hidden', 'name' => $this->getFieldName('attachmentId'), 'value' => $attachmentId, 'class' => 'ame-image-attachment-id', )); echo HtmlHelper::tag('input', array( 'type' => 'hidden', 'name' => $this->getFieldName('attachmentSiteId'), 'value' => $this->mainSetting['attachmentSiteId']->getValue(0), 'class' => 'ame-image-attachment-site-id', )); //Attachment URL will usually be overwritten on the server side, but it's useful //for screens that don't trigger server-side post-processing (e.g. the "Style" dialog). echo HtmlHelper::tag('input', array( 'type' => 'hidden', 'name' => $this->getFieldName('attachmentUrl'), 'value' => $this->mainSetting['attachmentUrl']->getValue(''), 'class' => 'ame-image-attachment-url', )); ?> 'hidden', 'name' => $this->getFieldName($dimension), 'value' => $this->mainSetting->getChildValue($dimension, ''), 'class' => 'ame-detected-image-' . $dimension, )); } ?>
> > isEnabled()) || (empty($attachmentId) && empty($externalUrl)) ) { echo ' style="display: none;" '; } ?>>Remove Image
outputSiblingDescription(); ?> '; //Close the container div. } protected static function enqueueDependencies() { static $done = false; if ( $done ) { return; } $done = true; parent::enqueueDependencies(); wp_enqueue_media(); wp_enqueue_auto_versioned_script( 'ame-image-selector-control-v2', plugins_url('assets/image-selector.js', AME_CUSTOMIZABLE_BASE_FILE), array('jquery', 'ame-lodash') ); wp_add_inline_script( 'ame-image-selector-control-v2', sprintf("var AmeIscBlogId = %d;", get_current_blog_id()) ); } protected function getKoComponentParams() { $params = parent::getKoComponentParams(); $params['externalUrlsAllowed'] = $this->mainSetting->areExternalUrlsAllowed(); $params['canSelectMedia'] = current_user_can('upload_files'); return $params; } }