Document version thumbnails are served up as full resolution and not transformed as expected
I am currently using version 4.1, but have tested using 4.1.3 and see the same issue.
I noticed that document thumbnails were being served as full resolution images instead of resized according to the DOCUMENTS_THUMBNAIL_WIDTH and DOCUMENTS_THUMBNAIL_HEIGHT settings.
(I am using the default settings, DOCUMENTS_THUMBNAIL_WIDTH set to 800 and DOCUMENTS_THUMBNAIL_HEIGHT not defined. I tried various combinations of settings to no effect.)
I installed 4.1.3 using docker-compose onto a test machine, and see the same issue with the "out-of-the-box" configuration.
Further investigation shows that document file thumbnails are resized as expected, just the document version thumbnails are affected.
Please see attached screenshot which probably does a better job of explaining the issue! As you can see, the thumbnail URL has no transform parameters and the image itself has a resolution of 2480 x 3509 pixels.
With a little help from #637 (closed), I think I have tracked this down to get_api_image_url
in mayan/apps/documents/models/document_version_models.py
I hacked up a fix which seems to work:
mayan/apps/documents/models/document_version_models.py:
def get_api_image_url(
self, maximum_layer_order=None, transformation_instance_list=None,
user=None
):
first_page = self.pages.first()
if first_page:
return first_page.get_api_image_url(
- maximum_layer_order=None, transformation_instance_list=None,
+ maximum_layer_order=maximum_layer_order, transformation_instance_list=transformation_instance_list,
user=user
)
else:
raise AppImageError(error_name=IMAGE_ERROR_NO_VERSION_PAGES)