__('Thumbnail', 'wpmf'),
'medium' => __('Medium', 'wpmf'),
'large' => __('Large', 'wpmf'),
'full' => __('Full Size', 'wpmf'),
));
$params = array(
'l18n' => array(
'block_image_lightbox_title' => __('WP Media Folder Image Lightbox', 'wpmf'),
),
'vars' => array(
'sizes' => $sizes
)
);
wp_localize_script('wpmf_lightbox_blocks', 'wpmf_lightbox_blocks', $params);
}
/**
* Add script to footer
*
* @return void
*/
public function adminFooterImagelightbox()
{
?>
true, 'url_thumb' => $url_image));
}
wp_send_json(array('status' => false));
}
/**
* Add media templates
*
* @return void
*/
public function printMediaTemplates()
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
if (isset($_GET['action']) && $_GET['action'] === 'elementor') {
return;
}
?>
ID, 'wpmf_image_lightbox', true);
if (empty($value)) {
$value = 'large';
}
$sizes = apply_filters('image_size_names_choose', array(
'thumbnail' => __('Thumbnail', 'wpmf'),
'medium' => __('Medium', 'wpmf'),
'large' => __('Large', 'wpmf'),
'full' => __('Full Size', 'wpmf'),
));
$option = '';
$option .= '';
foreach ($sizes as $k => $v) {
if ($value === $k) {
$option .= '';
} else {
$option .= '';
}
}
$form_fields['wpmf_image_lightbox'] = array(
'label' => __('Lightbox size', 'wpmf'),
'input' => 'html',
'html' => '
'
);
return $form_fields;
}
/**
* Save lightbox size field
* Based on /wp-admin/includes/media.php
*
* @param array $post An array of post data.
* @param array $attachment An array of attachment metadata.
*
* @return mixed $post
*/
public function attachmentFieldsToSave($post, $attachment)
{
if (isset($attachment['wpmf_image_lightbox'])) {
update_post_meta($post['ID'], 'wpmf_image_lightbox', $attachment['wpmf_image_lightbox']);
}
return $post;
}
}