Skip to content

Commit

Permalink
Add: vimeoQuery JiHong88#1410
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 authored and onedark23 committed Aug 12, 2024
1 parent 9d4f8df commit 12de90c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,10 @@ youtubeQuery : The query string of a YouTube embedded URL. default: ''
It takes precedence over the value user entered.
ex) 'autoplay=1&mute=1&enablejsapi=1&controls=0&rel=0&modestbranding=1'
// https://developers.google.com/youtube/player_parameters
vimeoQuery : The query string of a Vimeo embedded URL. default: '' {String}
It takes precedence over the value user entered.
ex) 'autoplay=1&muted=1'
// https://help.vimeo.com/hc/en-us/articles/12426260232977-Player-parameters-overview
videoFileInput : Choose whether to create a file input tag in the video upload window. default: false {Boolean}
videoUrlInput : Choose whether to create a video url input tag in the video upload window.
If the value of videoFileInput is false, it will be unconditionally. default: true {Boolean}
Expand Down
1 change: 1 addition & 0 deletions src/lib/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ export default {
options.videoRatio = (util.getNumber(options.videoRatio, 4) || 0.5625);
options.videoRatioList = !options.videoRatioList ? null : options.videoRatioList;
options.youtubeQuery = (options.youtubeQuery || '').replace('?', '');
options.vimeoQuery = (options.vimeoQuery || '').replace('?', '');
options.videoFileInput = !!options.videoFileInput;
options.videoUrlInput = (options.videoUrlInput === undefined || !options.videoFileInput) ? true : options.videoUrlInput;
options.videoUploadHeader = options.videoUploadHeader || null;
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/dialog/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default {
_align: 'none',
_floatClassRegExp: '__se__float\\-[a-z]+',
_youtubeQuery: options.youtubeQuery,
_vimeoQuery: options.vimeoQuery,
_videoRatio: (options.videoRatio * 100) + '%',
_defaultRatio: (options.videoRatio * 100) + '%',
_linkValue: '',
Expand Down Expand Up @@ -540,6 +541,15 @@ export default {
url = url.slice(0, -1);
}
url = 'https://player.vimeo.com/video/' + url.slice(url.lastIndexOf('/') + 1);

if (contextVideo._vimeoQuery.length > 0) {
if (/\?/.test(url)) {
const splitUrl = url.split('?');
url = splitUrl[0] + '?' + contextVideo._vimeoQuery + '&' + splitUrl[1];
} else {
url += '?' + contextVideo._vimeoQuery;
}
}
}

this.plugins.video.create_video.call(this, this.plugins.video[(!/embed|iframe|player|\/e\/|\.php|\.html?/.test(url) && !/vimeo\.com/.test(url) ? "createVideoTag" : "createIframeTag")].call(this), url, contextVideo.inputX.value, contextVideo.inputY.value, contextVideo._align, null, this.context.dialog.updateModal);
Expand Down

0 comments on commit 12de90c

Please sign in to comment.