-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add transcoded url meta #296
base: master
Are you sure you want to change the base?
Changes from 18 commits
970ef51
3c83e8a
319757b
ec4b1dc
0b7ded9
9ad669d
59ab2b9
aed778d
58fc8eb
54095d7
1db432e
3ca7e25
5cb6b57
9808a21
4e03d60
f4fa7f8
1e1ee7b
ca062ee
b5cff1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
**/*.build.js | ||
**/node_modules/** | ||
**/vendor/** | ||
assets/** | ||
build | ||
node_modules | ||
Gruntfile.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ sftp-config.json | |
*.sublime-workspace | ||
.editorconfig | ||
.cache/ | ||
package-lock.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v13.1.0 | ||
v18.20.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.transcoder-progress-bar { | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
bottom: -10px; | ||
height: 10px; | ||
background: rgba(0, 0, 0, 0.1); | ||
} | ||
.transcoder-progress-bar .progress { | ||
height: 100%; | ||
background: #21759b; | ||
transition: width 0.3s ease; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-end; | ||
} | ||
|
||
.transcoder-progress-bar .progress .progress-text { | ||
color: #fff; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php return array('dependencies' => array('react', 'wp-api-fetch'), 'version' => 'af1c6d65e659f17b25f0'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 Error: Expected 1 space after the array opener in a single line array. Found: no spaces (NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceAfterArrayOpenerSingleLine). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 Error: Expected 1 space before the array closer in a single line array. Found: no spaces (NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceBeforeArrayCloserSingleLine). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound). |
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
(function($) { | ||
$(document).ready(function() { | ||
if (typeof wp === 'undefined' || typeof wp.Uploader === 'undefined') { | ||
console.error('wp.Uploader is not available.'); | ||
return; | ||
} | ||
|
||
const progressBars = new Map(); | ||
|
||
// Check for existing video files in the media library. | ||
setTimeout(checkExistingVideoProgress, 500); | ||
|
||
// Listen for new files added to the queue. | ||
wp.Uploader.queue.on('add', function(file) { | ||
wp.Uploader.queue.on('reset', function() { | ||
// Only show progress bar for video files. | ||
if (file.attributes.type !== 'video') return; | ||
|
||
attachmentId = file.id; | ||
initializeProgressBar(attachmentId); | ||
}); | ||
}); | ||
|
||
/** | ||
* Initialize progress bar for the given attachment. | ||
* | ||
* @param {number} attachmentId | ||
*/ | ||
function initializeProgressBar(attachmentId) { | ||
const progressBar = $( | ||
`<div class="transcoder-progress-bar" style="display: none;"> | ||
<div class="progress" style="width: 0%;"> | ||
<span class="progress-text">0%</span> | ||
</div> | ||
</div>` | ||
); | ||
|
||
const mediaItemPreview = $(`.attachments .attachment[data-id="${attachmentId}"] .attachment-preview`); | ||
if (!mediaItemPreview.length) return; | ||
|
||
mediaItemPreview.append(progressBar); | ||
progressBars.set(attachmentId, progressBar); | ||
monitorProgress(attachmentId); | ||
} | ||
|
||
|
||
/** | ||
* Check for existing video files in the media. | ||
* | ||
*/ | ||
function checkExistingVideoProgress() { | ||
const videoQuery = wp.media.query({ | ||
type: 'video', | ||
posts_per_page: -1, | ||
}); | ||
|
||
videoQuery.more().done(function() { | ||
const videoAttachments = videoQuery.models; | ||
videoAttachments.forEach(function(attachment) { | ||
const attachmentId = attachment.id; | ||
initializeProgressBar(attachmentId); | ||
}) | ||
}); | ||
} | ||
|
||
|
||
/** | ||
* Monitor the transcoding progress of the given attachment. | ||
* | ||
* @param {number} attachmentId | ||
*/ | ||
function monitorProgress(attachmentId) { | ||
const progressBar = progressBars.get(attachmentId); | ||
if (!progressBar) return; | ||
|
||
$.ajax({ | ||
url: `${transcoderSettings.restUrl}/${attachmentId}`, | ||
method: 'GET', | ||
beforeSend: xhr => xhr.setRequestHeader('X-WP-Nonce', transcoderSettings.nonce), | ||
success: function(data) { | ||
const progress = parseFloat(data.progress) || 0; | ||
progressBar.show(); | ||
progressBar.find('.progress').css('width', `${progress}%`); | ||
progressBar.find('.progress-text').text(`${progress}%`); | ||
|
||
if (progress < 100) { | ||
setTimeout(() => monitorProgress(attachmentId), 5000); | ||
} else { | ||
progressBar.remove(); | ||
progressBars.delete(attachmentId); | ||
} | ||
}, | ||
error: function() { | ||
setTimeout(() => monitorProgress(attachmentId), 5000); | ||
} | ||
}); | ||
} | ||
}); | ||
})(jQuery); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing file doc comment (Squiz.Commenting.FileComment.Missing).