Skip to content

Commit 43954c6

Browse files
committed
Merge branch 'fix-video-field'
2 parents 57b4168 + 268fdf4 commit 43954c6

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ All Notable changes to `Backpack CRUD` will be documented in this file.
88

99
-----------
1010

11+
## 4.0.41 - 2020-02-16
12+
13+
### Fixed
14+
- merged #2450 - video field now has customizable youtube api key;
15+
16+
1117
## 4.0.40 - 2020-02-10
1218

1319
### Fixed

src/resources/views/crud/fields/video.blade.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
$value = $value;
1313
}
1414
15+
$field['youtube_api_key'] = $field['youtube_api_key'] ?? 'AIzaSyDQa76EpdNPzfeTAoZUut2AnvBA0jkx3FI';
16+
1517
?>
1618

1719

18-
<div data-video data-init-function="bpFieldInitVideoElement" @include('crud::inc.field_wrapper_attributes') >
20+
<div data-video data-init-function="bpFieldInitVideoElement" data-youtube-api-key="{{$field['youtube_api_key']}}" @include('crud::inc.field_wrapper_attributes') >
1921
<label for="{{ $field['name'] }}_link">{!! $field['label'] !!}</label>
2022
@include('crud::inc.field_translatable_icon')
2123
<input class="video-json" type="hidden" name="{{ $field['name'] }}" value="{{ $value }}">
@@ -145,9 +147,9 @@
145147
return id;
146148
};
147149
148-
var fetchYouTube = function( videoId, callback ){
150+
var fetchYouTube = function( videoId, callback, apiKey ){
149151
150-
var api = 'https://www.googleapis.com/youtube/v3/videos?id='+videoId+'&key=AIzaSyDQa76EpdNPzfeTAoZUut2AnvBA0jkx3FI&part=snippet';
152+
var api = 'https://www.googleapis.com/youtube/v3/videos?id='+videoId+'&key='+apiKey+'&part=snippet';
151153
152154
var video = {
153155
provider: 'youtube',
@@ -199,7 +201,7 @@
199201
});
200202
};
201203
202-
var parseVideoLink = function( link, callback ){
204+
var parseVideoLink = function( link, callback, apiKey ){
203205
204206
var response = {success: false, message: 'unknown error occured, please try again', data: [] };
205207
@@ -211,7 +213,7 @@
211213
}
212214
213215
214-
var id = tryYouTube(link);
216+
var id = tryYouTube(link, apiKey);
215217
216218
if( id ){
217219
@@ -224,7 +226,7 @@
224226
}
225227
226228
callback(response);
227-
});
229+
},apiKey);
228230
}
229231
else {
230232
@@ -281,7 +283,8 @@ function bpFieldInitVideoElement(element) {
281283
jsonField = $this.find('.video-json'),
282284
linkField = $this.find('.video-link'),
283285
pDummy = $this.find('.video-dummy'),
284-
pWrap = $this.find('.video-preview');
286+
pWrap = $this.find('.video-preview'),
287+
apiKey = $this.attr('data-youtube-api-key');
285288
286289
try {
287290
var videoJson = JSON.parse(jsonField.val());
@@ -325,7 +328,7 @@ function bpFieldInitVideoElement(element) {
325328
}
326329
327330
videoParsing = false;
328-
});
331+
},apiKey);
329332
}
330333
else {
331334
videoParsing = false;

0 commit comments

Comments
 (0)