diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index bad53f63e..4e7ff032a 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -297,11 +297,10 @@ class ServiceItem(RegistryProperties): if background: self.image_border = background self.service_item_type = ServiceItemType.Image - # 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._raw_frames.append({'title': title, 'path': path}) + else: + self._raw_frames.append({'title': title, 'path': path, 'image': thumbnail}) self.image_manager.add_image(path, ImageSource.ImagePlugin, self.image_border) self._new_item() diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index de69e809f..4f9e87751 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -125,7 +125,7 @@ from mako.template import Template from PyQt4 import QtCore from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, translate -from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities +from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities, create_thumb log = logging.getLogger(__name__) FILE_TYPES = { @@ -508,6 +508,9 @@ class HttpRouter(RegistryProperties): 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']) + # Create thumbnail if it doesn't exists + if not os.path.exists(thumbnail_path): + create_thumb(current_item.get_frame_path(), thumbnail_path, False) item['img'] = urllib.request.pathname2url(thumbnail_path) item['text'] = str(frame['title']) item['html'] = str(frame['title']) diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index d92220821..629b17114 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -111,8 +111,7 @@ class TestServiceItem(TestCase): # GIVEN: A new service item and a mocked add icon function image_name = 'image_1.jpg' test_file = os.path.join(TEST_PATH, image_name) - thumb_file = os.path.normpath(os.path.join('/path/thumbnails', image_name)) - frame_array = {'path': test_file, 'title': image_name, 'image': thumb_file} + frame_array = {'path': test_file, 'title': image_name} service_item = ServiceItem(None) service_item.add_icon = MagicMock() @@ -158,10 +157,8 @@ class TestServiceItem(TestCase): image_name2 = 'image_2.jpg' test_file1 = os.path.normpath(os.path.join('/home/openlp', image_name1)) test_file2 = os.path.normpath(os.path.join('/home/openlp', image_name2)) - thumb_file1 = os.path.normpath(os.path.join('/path/thumbnails', image_name1)) - thumb_file2 = os.path.normpath(os.path.join('/path/thumbnails', image_name2)) - frame_array1 = {'path': test_file1, 'title': image_name1, 'image': thumb_file1} - frame_array2 = {'path': test_file2, 'title': image_name2, 'image': thumb_file2} + frame_array1 = {'path': test_file1, 'title': image_name1} + frame_array2 = {'path': test_file2, 'title': image_name2} service_item = ServiceItem(None) service_item.add_icon = MagicMock()