forked from openlp/openlp
Added thumbnails for images from serviceitems
This commit is contained in:
parent
2fbbc85679
commit
8d76aeffd2
@ -39,8 +39,8 @@ import uuid
|
|||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.common import RegistryProperties, Settings, translate
|
from openlp.core.common import RegistryProperties, Settings, translate, AppLocation
|
||||||
from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags
|
from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags, create_thumb
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -292,16 +292,17 @@ class ServiceItem(RegistryProperties):
|
|||||||
:param path: The directory in which the image file is located.
|
:param path: The directory in which the image file is located.
|
||||||
:param title: A title for the slide in the service item.
|
:param title: A title for the slide in the service item.
|
||||||
:param background:
|
:param background:
|
||||||
:param thumbnail: Optional alternative thumbnail, used for remote thumbnails.
|
:param thumbnail: Optional thumbnail, used for remote thumbnails.
|
||||||
"""
|
"""
|
||||||
if background:
|
if background:
|
||||||
self.image_border = background
|
self.image_border = background
|
||||||
self.service_item_type = ServiceItemType.Image
|
self.service_item_type = ServiceItemType.Image
|
||||||
if thumbnail:
|
# If no thumbnail was given we create one
|
||||||
self._raw_frames.append({'title': title, 'path': path, 'image': thumbnail})
|
if not thumbnail:
|
||||||
self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border)
|
thumbnail = os.path.join(AppLocation.get_section_data_path('images'), 'thumbnails', os.path.split(path)[1])
|
||||||
else:
|
create_thumb(path, thumbnail, False)
|
||||||
self._raw_frames.append({'title': title, 'path': path})
|
self._raw_frames.append({'title': title, 'path': path, 'image': thumbnail})
|
||||||
|
self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border)
|
||||||
self.image_manager.add_image(path, ImageSource.ImagePlugin, self.image_border)
|
self.image_manager.add_image(path, ImageSource.ImagePlugin, self.image_border)
|
||||||
self._new_item()
|
self._new_item()
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
# Continue with the existing images.
|
# Continue with the existing images.
|
||||||
for filename in images_file_names:
|
for filename in images_file_names:
|
||||||
name = os.path.split(filename)[1]
|
name = os.path.split(filename)[1]
|
||||||
service_item.add_from_image(filename, name, background)
|
service_item.add_from_image(filename, name, background, os.path.join(self.service_path, name))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_group_exists(self, new_group):
|
def check_group_exists(self, new_group):
|
||||||
|
@ -407,7 +407,6 @@ class HttpRouter(RegistryProperties):
|
|||||||
'thumbnails/' + full_path))
|
'thumbnails/' + full_path))
|
||||||
if os.path.exists(full_path):
|
if os.path.exists(full_path):
|
||||||
path, just_file_name = os.path.split(full_path)
|
path, just_file_name = os.path.split(full_path)
|
||||||
self.image_manager.add_image(full_path, just_file_name, None, width, height)
|
|
||||||
ext, content_type = self.get_content_type(full_path)
|
ext, content_type = self.get_content_type(full_path)
|
||||||
image = self.image_manager.get_image(full_path, just_file_name, width, height)
|
image = self.image_manager.get_image(full_path, just_file_name, width, height)
|
||||||
content = image_to_byte(image, False)
|
content = image_to_byte(image, False)
|
||||||
@ -504,8 +503,8 @@ class HttpRouter(RegistryProperties):
|
|||||||
item['tag'] = str(index + 1)
|
item['tag'] = str(index + 1)
|
||||||
item['text'] = str(frame['text'])
|
item['text'] = str(frame['text'])
|
||||||
item['html'] = str(frame['html'])
|
item['html'] = str(frame['html'])
|
||||||
# Handle images, unless a custom thumbnail is given or if thumbnails is disabled
|
# Handle images, unless a thumbnail is given or if thumbnails is disabled
|
||||||
elif current_item.is_image() and not frame.get('image', None) and Settings().value('remotes/thumbnails'):
|
elif current_item.is_image() and not frame.get('image', '') and Settings().value('remotes/thumbnails'):
|
||||||
item['tag'] = str(index + 1)
|
item['tag'] = str(index + 1)
|
||||||
thumbnail_path = os.path.sep + os.path.join('images', 'thumbnails', frame['title'])
|
thumbnail_path = os.path.sep + os.path.join('images', 'thumbnails', frame['title'])
|
||||||
item['img'] = urllib.request.pathname2url(thumbnail_path)
|
item['img'] = urllib.request.pathname2url(thumbnail_path)
|
||||||
|
Loading…
Reference in New Issue
Block a user