Skip to content

Commit

Permalink
* Fixes for PHP 8.x compatibility
Browse files Browse the repository at this point in the history
* Implement changing poster image for video files
* Fixed how additional buttons are displayed on attachment detail pages
* Fixed downloading video with video player
* Fix for getting rendition URL for mux encoded videos
* Updated video.js library to 7.20.3
* Updated related video.js plugins to latest versions
* Fix mux transfer task to work with large files and give better feedback.  Note: Mux transfers wait until the mp4 renditions are encoded by mux before transferring.  This can take a while for large files.
* Remove preflight admin notice
* Added support for Supabase Storage.  This support is only provided for specific development scenarios, you should not use Supabase Storage for general purpose storage because you think it's inexpensive.  Supabase Storage support is for when you need to *integrate* with an application already using Supabase.
* Added a new `Transfer Mux Video` task that allows you to transfer encoded videos from Mux to cloud or local storage to serve the videos from other services and CDNs instead of Mux.  Use Mux to encode, serve the result elsewhere.
* Added a `Regenerate Filmstrip` task to generate new filmstrips for Mux encoded videos that might not have had them generated.
* The Gutenberg block now supports outputting the video's dimension to insure that there isn't any reflow on document load.
* Fixed INFO log messages with regards to PHP 8.1.
* Transferred Mux videos display HLS logo instead of the Mux logo in the media library.
* In the list view in the Media Library, the Mux or HLS logo is now displayed.
* The `Relink Mux Video` task will relink any videos that were transferred with the `Transfer Mux Video` task unless they've been deleted on Mux.
* You can setup Media Cloud to automatically transfer Mux encoded videos to local or cloud storage after they've finished being encoded by Mux.
* Added `wp mediacloud:video transfer` command to transfer videos from Mux to cloud or local storage.
* Added `wp mediacloud:video relink` command to relink videos that were transferred from Mux to local or cloud storage.
* Added toggle to `Video Player` settings to replace the WordPress admin default video player with the native video player using HLS.js.  This allows you to preview Mux encoded videos in the admin without having to create a post.
* Added toggle to override the default WordPress video shortcode and replace it with the Media Cloud Video Player.  You should, however, consider switching to the Media Cloud Video Player shortcode instead because it performs better.
* The Elementor Media Cloud Video Player widget now supports playing non-Mux videos.
* Added `hls` object to WP REST Attachment object that includes the playlist url, poster image url, filmstrip url, width, height, duration, mp4 fallback rendition url and subtitles.
* Added the ability to add captions (via a VTT text file) to any video, regardless if it's Mux encoded or not.  This feature is available on the edit detail screen for a video attachment.  You must be using the Media Cloud Video Player feature.
* Removed `yuloh/bccomp-polyfill` dependency.
  • Loading branch information
jawngee committed Oct 6, 2022
1 parent b841444 commit f262efc
Show file tree
Hide file tree
Showing 137 changed files with 6,337 additions and 4,497 deletions.
36 changes: 28 additions & 8 deletions classes/Tasks/AttachmentTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,27 @@ protected function updateCurrentPost($post_id) {

$this->currentTitle = get_post_field('post_title', $post_id);

$thumb = wp_get_attachment_image_src($post_id, 'thumbnail', true);
if (!empty($thumb)) {
$this->currentThumb = $thumb[0];
$this->isIcon = (($thumb[1] != 150) && ($thumb[2] != 150));
if (strpos(get_post_mime_type($post_id), 'video/') === 0) {
$thumb = get_the_post_thumbnail_url($post_id, 'thumbnail');
if (!empty($thumb)) {
$this->currentThumb = $thumb;
$this->isIcon = false;
} else {
$this->currentThumb = null;
$this->isIcon = false;
}
} else {
$this->currentThumb = null;
$this->isIcon = false;
$thumb = wp_get_attachment_image_src($post_id, 'thumbnail', true);
if (!empty($thumb)) {
$this->currentThumb = $thumb[0];
$this->isIcon = (($thumb[1] != 150) && ($thumb[2] != 150));
} else {
$this->currentThumb = null;
$this->isIcon = false;
}
}


$this->save();
}

Expand Down Expand Up @@ -87,7 +99,9 @@ public function prepare($options = [], $selectedItems = []) {

if (!empty($selectedItems) && is_array($selectedItems)) {
foreach($selectedItems as $postId) {
$this->addItem($this->filterItem(['id' => $postId], $options));
if (!$this->addDataForPost($postId, $options)) {
$this->addItem($this->filterItem(['id' => $postId], $options));
}
}
} else {
$args = [
Expand Down Expand Up @@ -135,7 +149,9 @@ public function prepare($options = [], $selectedItems = []) {
}

foreach($postIds as $postId) {
$this->addItem($this->filterItem(['id' => $postId], $options));
if (!$this->addDataForPost($postId, $options)) {
$this->addItem($this->filterItem(['id' => $postId], $options));
}
}
}

Expand All @@ -145,4 +161,8 @@ public function prepare($options = [], $selectedItems = []) {
return ($this->totalItems > 0);
}

protected function addDataForPost($postId, $options):bool {
return false;
}

}
1 change: 1 addition & 0 deletions classes/Tasks/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ public static function markConfirmed() {

//region JSON

#[\ReturnTypeWillChange]
public function jsonSerialize() {
if ($this->state >= self::STATE_COMPLETE) {
$remaining = 0;
Expand Down
1 change: 1 addition & 0 deletions classes/Tasks/TaskSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ public static function hasScheduledTaskOfType($type) {
//endregion

//region JSON
#[\ReturnTypeWillChange]
public function jsonSerialize() {
return [
'id' => $this->id,
Expand Down
103 changes: 43 additions & 60 deletions classes/Tools/Crop/CropTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,67 +127,50 @@ private function hookupUI()
return $content;
},10,2);

add_action( 'wp_enqueue_media', function () {
remove_action('admin_footer', 'wp_print_media_templates');

add_action('admin_footer', function(){
ob_start();
wp_print_media_templates();
$result=ob_get_clean();
echo $result;


$sizes=ilab_get_image_sizes();
$sizeKeys=array_keys($sizes);

ob_start();
?>
<script>
jQuery(document).ready(function() {
jQuery('input[type="button"]')
.filter(function() {
return this.id.match(/imgedit-open-btn-[0-9]+/);
})
.each(function(){
var image_id=this.id.match(/imgedit-open-btn-([0-9]+)/)[1];
var button=jQuery('<input type="button" class="button" style="margin-left:5px;" value="Crop Image">');
jQuery(this).after(button);

button.on('click',function(e){
e.preventDefault();
ILabModal.loadURL("<?php echo get_admin_url(null, 'admin-ajax.php')?>?action=ilab_crop_image_page&size=<?php echo $sizeKeys[0]?>&post="+image_id,false,null);

return false;
});
});

attachTemplate=jQuery('#tmpl-image-details');
if (attachTemplate) {
attachTemplate.text(attachTemplate.text().replace(/(<input type="button" class="replace-attachment button")/, '<a href="<?php echo $this->cropPageURL('{{data.attachment.id}}')?>" class="ilab-thickbox button"><?php echo __('Crop Image') ?></a>&nbsp;$1'));
}

attachTemplate=jQuery('#tmpl-attachment-details-two-column');
if (attachTemplate)
{
attachTemplate.text(attachTemplate.text().replace(/(<button(?:.*)class="(?:.*)edit-attachment(?:.*)"[^>]*[^<]+<\/button>)/,'$1&nbsp;<a href="<?php echo $this->cropPageURL('{{data.id}}')?>" class="ilab-thickbox button"><?php echo __('Crop Image') ?></a>'));
attachTemplate.text(attachTemplate.text().replace(/(<a(?:.*)class="(?:.*)edit-imgix(?:.*)"[^>]*[^<]+<\/a>)/,'$1&nbsp;<a href="<?php echo $this->cropPageURL('{{data.id}}')?>" class="ilab-thickbox button"><?php echo __('Crop Image') ?></a>'));
attachTemplate.text(attachTemplate.text().replace(/(<a class="(?:.*)edit-attachment(?:.*)"[^>]+[^<]+<\/a>)/,'$1&nbsp;<a href="<?php echo $this->cropPageURL('{{data.id}}')?>" class="ilab-thickbox button"><?php echo __('Crop Image') ?></a>'));
attachTemplate.text(attachTemplate.text().replace(/(<a class="(?:.*)view-attachment(?:.*)"[^>]+[^<]+<\/a>)/,'$1 | <a class="ilab-thickbox" href="<?php echo $this->cropPageURL('{{data.id}}')?>"><?php echo __('Crop Image') ?></a>'));
}

attachTemplate=jQuery('#tmpl-attachment-details');
if (attachTemplate)
{
attachTemplate.text(attachTemplate.text().replace(/(<a(?:.*)class="(?:.*)edit-imgix(?:.*)"[^>]*[^<]+<\/a>)/, '$1<a class="ilab-thickbox" style="display:block" href="<?php echo $this->cropPageURL('{{data.id}}')?>"><?php echo __('Crop Image') ?></a>'));
attachTemplate.text(attachTemplate.text().replace(/(<a class="(?:.*)edit-attachment(?:.*)"[^>]+[^<]+<\/a>)/, '$1\n<a class="ilab-thickbox" style="display:block" href="<?php echo $this->cropPageURL('{{data.id}}')?>"><?php echo __('Crop Image') ?></a>'));
}
add_filter('mediacloud/ui/media-detail-buttons', function($buttons) {
$buttons[] = [
'type' => 'image',
'label' => __('Crop Image'),
'url' => $this->cropPageURL('__ID__'),
];

return $buttons;
}, 1);

add_filter('mediacloud/ui/media-detail-links', function($links) {
$links[] = [
'type' => 'image',
'label' => __('Crop Image'),
'url' => $this->cropPageURL('__ID__'),
];

return $links;
}, 1);

add_action('mediacloud/ui/media-detail-buttons-extra', function() {
$sizes=ilab_get_image_sizes();
$sizeKeys=array_keys($sizes);
$adminUrl = get_admin_url(null, 'admin-ajax.php');

echo <<<COOL
jQuery('input[type="button"]')
.filter(function() {
return this.id.match(/imgedit-open-btn-[0-9]+/);
})
.each(function(){
var image_id=this.id.match(/imgedit-open-btn-([0-9]+)/)[1];
var button=jQuery('<input type="button" class="button" style="margin-left:5px;" value="Crop Image">');
jQuery(this).after(button);
button.on('click',function(e){
e.preventDefault();
ILabModal.loadURL("{$adminUrl}?action=ilab_crop_image_page&size={$sizeKeys[0]}&post="+image_id,false,null);
return false;
});
});
</script>
<?php
$result=ob_get_clean();
echo $result;
}, PHP_INT_MAX);
} );
COOL;
}, 1);
}

/**
Expand Down
116 changes: 59 additions & 57 deletions classes/Tools/DynamicImages/DynamicImagesTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,71 +434,73 @@ public function enqueueTheGoods($hook) {
*/
private function hookupUI() {
add_filter('media_row_actions', function($actions, $post) {
$newaction['ilab_edit_image'] = '<a class="ilab-thickbox" href="'.$this->editPageURL($post->ID).'" title="Edit Image">'.__('Edit Image').'</a>';
if (strpos($post->post_mime_type, 'image') === 0) {
$meta = wp_get_attachment_metadata($post->ID);
if (empty(arrayPath($meta, 's3', null))) {
return $actions;
}

$newaction['ilab_edit_image'] = '<a class="ilab-thickbox" href="' . $this->editPageURL($post->ID) . '" title="Edit Image">' . __('Edit Image') . '</a>';
return array_merge($actions, $newaction);
}

return array_merge($actions, $newaction);
return $actions;
}, 10, 2);

add_action('wp_enqueue_media', function() {
remove_action('admin_footer', 'wp_print_media_templates');

add_action('admin_footer', function() {
ob_start();
wp_print_media_templates();
$result = ob_get_clean();
echo $result;


?>
<script>
jQuery(document).ready(function () {

jQuery('input[type="button"]')
.filter(function () {
return this.id.match(/imgedit-open-btn-[0-9]+/);
})
.each(function () {
var image_id = this.id.match(/imgedit-open-btn-([0-9]+)/)[1];
var button = jQuery(this);
button.off('click');
button.attr('onclick', null);
button.on('click', function (e) {
e.preventDefault();

ILabModal.loadURL("<?php echo get_admin_url(null, 'admin-ajax.php')?>?action=ilab_dynamic_images_edit_page&image_id=" + image_id, false, null);

return false;
});
});

jQuery(document).on('click', '.ilab-edit-attachment', function (e) {
var button = jQuery(this);
var image_id = button.data('id');
e.preventDefault();

ILabModal.loadURL("<?php echo get_admin_url(null, 'admin-ajax.php')?>?action=ilab_dynamic_images_edit_page&image_id=" + image_id, false, null);

add_filter('mediacloud/ui/media-detail-buttons', function($buttons) {
$buttons[] = [
'type' => 'image',
'cloudonly' => true,
'label' => __('Edit Image'),
'url' => $this->editPageURL('__ID__'),
];

return $buttons;
}, 2);

add_filter('mediacloud/ui/media-detail-links', function($links) {
$links[] = [
'type' => 'image',
'cloudonly' => true,
'label' => __('Edit Image'),
'url' => $this->editPageURL('__ID__'),
];

return $links;
}, 2);

add_filter('mediacloud/ui/media-detail-remove', function($toRemove) {
$toRemove[] = "'<button type=\"button\" class=\"button edit-attachment\">".translate('Edit Image')."</button>'";
$toRemove[] = '/(<a class="(?:.*)edit-attachment(?:.*)"[^>]+[^<]+<\/a>)/';

return $toRemove;
}, 2);

add_action('mediacloud/ui/media-detail-buttons-extra', function() {
$adminUrl = get_admin_url(null, 'admin-ajax.php');

echo <<<COOL
jQuery('input[type="button"]')
.filter(function () {
return this.id.match(/imgedit-open-btn-[0-9]+/);
})
.each(function () {
var image_id = this.id.match(/imgedit-open-btn-([0-9]+)/)[1];
var button = jQuery(this);
button.off('click');
button.attr('onclick', null);
button.on('click', function (e) {
e.preventDefault();
ILabModal.loadURL("{$adminUrl}?action=ilab_dynamic_images_edit_page&image_id=" + image_id, false, null);
return false;
});

attachTemplate = jQuery('#tmpl-attachment-details-two-column');
if (attachTemplate) {
attachTemplate.text(attachTemplate.text().replace('<button type="button" class="button edit-attachment"><?php _e('Edit Image'); ?></button>', '<button type="button" data-id="{{data.id}}" class="button ilab-edit-attachment"><?php _e('Edit Image'); ?></button>'));
}

attachTemplate = jQuery('#tmpl-attachment-details-two-column');
if (attachTemplate) {
attachTemplate.text(attachTemplate.text().replace(/(<a class="(?:.*)edit-attachment(?:.*)"[^>]+[^<]+<\/a>)/, '<a href="<?php echo $this->editPageURL('{{data.id}}')?>" class="ilab-thickbox button edit-imgix"><?php echo __('Edit Image') ?></a>'));
}

attachTemplate = jQuery('#tmpl-attachment-details');
if (attachTemplate)
attachTemplate.text(attachTemplate.text().replace(/(<a class="(?:.*)edit-attachment(?:.*)"[^>]+[^<]+<\/a>)/, '<a class="ilab-thickbox edit-imgix" href="<?php echo $this->editPageURL('{{data.id}}')?>"><?php echo __('Edit Image') ?></a>'));
});
</script>
<?php
});
});
COOL;
}, 2);
}

/**
Expand Down
Loading

0 comments on commit f262efc

Please sign in to comment.