Added thumbnails for images from serviceitems

This commit is contained in:
Tomas Groth 2014-09-10 07:40:12 +01:00
parent 2fbbc85679
commit 8d76aeffd2
3 changed files with 12 additions and 12 deletions

View File

@ -39,8 +39,8 @@ import uuid
from PyQt4 import QtGui
from openlp.core.common import RegistryProperties, Settings, translate
from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags
from openlp.core.common import RegistryProperties, Settings, translate, AppLocation
from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags, create_thumb
log = logging.getLogger(__name__)
@ -292,16 +292,17 @@ class ServiceItem(RegistryProperties):
:param path: The directory in which the image file is located.
:param title: A title for the slide in the service item.
:param background:
:param thumbnail: Optional alternative thumbnail, used for remote thumbnails.
:param thumbnail: Optional thumbnail, used for remote thumbnails.
"""
if background:
self.image_border = background
self.service_item_type = ServiceItemType.Image
if thumbnail:
self._raw_frames.append({'title': title, 'path': path, 'image': thumbnail})
self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border)
else:
self._raw_frames.append({'title': title, 'path': path})
# If no thumbnail was given we create one
if not thumbnail:
thumbnail = os.path.join(AppLocation.get_section_data_path('images'), 'thumbnails', os.path.split(path)[1])
create_thumb(path, thumbnail, False)
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._new_item()

View File

@ -590,7 +590,7 @@ class ImageMediaItem(MediaManagerItem):
# Continue with the existing images.
for filename in images_file_names:
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
def check_group_exists(self, new_group):

View File

@ -407,7 +407,6 @@ class HttpRouter(RegistryProperties):
'thumbnails/' + full_path))
if os.path.exists(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)
image = self.image_manager.get_image(full_path, just_file_name, width, height)
content = image_to_byte(image, False)
@ -504,8 +503,8 @@ class HttpRouter(RegistryProperties):
item['tag'] = str(index + 1)
item['text'] = str(frame['text'])
item['html'] = str(frame['html'])
# Handle images, unless a custom thumbnail is given or if thumbnails is disabled
elif current_item.is_image() and not frame.get('image', None) and Settings().value('remotes/thumbnails'):
# Handle images, unless a thumbnail is given or if thumbnails is disabled
elif current_item.is_image() and not frame.get('image', '') and Settings().value('remotes/thumbnails'):
item['tag'] = str(index + 1)
thumbnail_path = os.path.sep + os.path.join('images', 'thumbnails', frame['title'])
item['img'] = urllib.request.pathname2url(thumbnail_path)