26 lines
718 B
JavaScript
26 lines
718 B
JavaScript
hexo.extend.tag.register('oss_video', function(args) {
|
|
let { config } = hexo;
|
|
|
|
let src = args.shift() || '';
|
|
// let versionId = args[1] || '';
|
|
if (src.length === 0) {
|
|
return '';
|
|
}
|
|
let fullUrl = `${config.oss.endpoint}/${src}`;
|
|
let affix = src.substring(src.lastIndexOf('.') + 1);
|
|
|
|
let attrs = []
|
|
attrs.push('controls');
|
|
attrs.push('muted="true"');
|
|
|
|
let width = args.shift() || 0;
|
|
let height = args.shift() || 0;
|
|
if (width !== 0) {
|
|
attrs.push(`width="${width}"`);
|
|
}
|
|
if (height !== 0) {
|
|
attrs.push(`height="${height}"`);
|
|
}
|
|
|
|
return `<video ${attrs.join(' ')}><source src="${fullUrl}"} type="video/${affix}"></video>`;
|
|
}); |