mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: When editing metadata add a button to remove the existing cover. Note that after removing the cover a auto-generated cover is displayed instead. You might need to hit refresh in your browser to see the change. Fixes #1794123 [[Enhancement] Content Server: add option to remove cover and/or generate default cover](https://bugs.launchpad.net/calibre/+bug/1794123)
This commit is contained in:
parent
cef074948d
commit
d912119e8f
@ -557,10 +557,20 @@ def cover_chosen(top_container_id, book_id, container_id, files):
|
|||||||
cover_chosen.counter = 0
|
cover_chosen.counter = 0
|
||||||
|
|
||||||
|
|
||||||
|
def remove_cover(top_container_id, book_id):
|
||||||
|
nonlocal has_changes
|
||||||
|
changes.cover = '--remove--'
|
||||||
|
has_changes = True
|
||||||
|
on_close(top_container_id)
|
||||||
|
|
||||||
|
|
||||||
def cover_edit(container_id, book_id, field, fm, div, mi):
|
def cover_edit(container_id, book_id, field, fm, div, mi):
|
||||||
upload_files_widget(div, cover_chosen.bind(None, container_id, book_id), _(
|
upload_files_widget(div, cover_chosen.bind(None, container_id, book_id), _(
|
||||||
'Change the cover by <a>selecting the cover image</a> or drag and drop of the cover image here.'),
|
'Change the cover by <a>selecting the cover image</a> or drag and drop of the cover image here.'),
|
||||||
single_file=True, accept_extensions='png jpeg jpg')
|
single_file=True, accept_extensions='png jpeg jpg')
|
||||||
|
div.appendChild(E.div(
|
||||||
|
style='padding: 1rem',
|
||||||
|
create_button(_('Remove existing cover'), action=remove_cover.bind(None, container_id, book_id))))
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -818,6 +828,10 @@ def render_metadata(mi, table, container_id, book_id): # {{{
|
|||||||
style='max-width: 300px; max-height: 400px',
|
style='max-width: 300px; max-height: 400px',
|
||||||
)
|
)
|
||||||
if changes.cover:
|
if changes.cover:
|
||||||
|
if changes.cover is '--remove--':
|
||||||
|
img.removeAttribute('src')
|
||||||
|
changes.cover = None
|
||||||
|
else:
|
||||||
r = FileReader()
|
r = FileReader()
|
||||||
r.onload = def(evt):
|
r.onload = def(evt):
|
||||||
img.src = evt.target.result
|
img.src = evt.target.result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user