Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Wagtail Videos
Commits
a2b3dd9a
Unverified
Commit
a2b3dd9a
authored
Oct 24, 2022
by
Seb Brown
Committed by
GitHub
Oct 24, 2022
Browse files
Merge pull request #94 from 13hakta/preview
Load preview image in editor
parents
f7e32ed2
67050185
Changes
2
Hide whitespace changes
Inline
Side-by-side
wagtailvideos/static/wagtailvideos/js/video-chooser.js
View file @
a2b3dd9a
...
...
@@ -4,6 +4,19 @@ function createVideoChooser(id) {
var
input
=
$
(
'
#
'
+
id
);
var
editLink
=
chooserElement
.
find
(
'
.edit-link
'
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
event
=>
{
$
.
ajax
(
window
.
chooserUrls
.
videoChooser
+
input
.
val
()).
done
(
data
=>
{
let
videoData
=
data
.
result
input
.
val
(
videoData
.
id
);
previewVideo
.
attr
({
src
:
videoData
.
preview
.
url
,
alt
:
videoData
.
title
});
chooserElement
.
removeClass
(
'
blank
'
);
editLink
.
attr
(
'
href
'
,
videoData
.
edit_link
);
});
});
$
(
'
.action-choose
'
,
chooserElement
).
click
(
function
()
{
ModalWorkflow
({
url
:
window
.
chooserUrls
.
videoChooser
,
...
...
wagtailvideos/widgets.py
View file @
a2b3dd9a
...
...
@@ -17,14 +17,15 @@ class AdminVideoChooser(AdminChooser):
self
.
video_model
=
get_video_model
()
def
render_html
(
self
,
name
,
value
,
attrs
):
instance
,
value
=
self
.
get_instance_and_id
(
self
.
video_model
,
value
)
instance
,
value_data
=
self
.
get_instance_and_id
(
self
.
video_model
,
value
)
original_field_html
=
super
(
AdminVideoChooser
,
self
).
render_html
(
name
,
value
,
attrs
)
return
render_to_string
(
"wagtailvideos/widgets/video_chooser.html"
,
{
'widget'
:
self
,
'original_field_html'
:
original_field_html
,
'attrs'
:
attrs
,
'value'
:
value
,
'value'
:
value
_data
,
'video'
:
instance
,
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment