Package: odoo-addon-search-engine-image-thumbnail
This module is a technical module with the purpose of easing the export
of image thumbnails to a search engine index.It extends the functionality of theconnector_search_enginemodule
by adding specialized methods that can be used to get and generate
thumbnails from an image you want to index.ImportantThis is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.More details on development statusTable of contentsUse Cases / ContextConfigurationUsageBug TrackerCreditsAuthorsContributorsOther creditsMaintainersUse Cases / ContextWhen you export images to an index, you may want to ensure that the
images are exported in a format and size that is suitable for the
application that will consume the index.This module depends on thefs_image_thumdbnailmodule. This last one provides a method and a mixin used to generate
thumbnails from aFSImageValueobject.ConfigurationIf you want to force the format of the generated thumbnail, you define a
a configuration parameter into Odoo with the keyfs_image_thumbnail.resize_formatand the value PNG or JPEG or GIF or
ICO. Otherwise, the format of the generated thumbnail will be the same
as the format of the original image.UsageAs specified, this module will not add any new features by itself once
installed. As a developer, you can depend on this module to benefit from
a set of specialized methods that can be used to get and generate
thumbnails from an image you want to index.Behind the scenes, this module extend these.indexable.recormodel
by adding 2 new methods:_get_or_create_thumbnails_for_multi_images: This method is used
to get or create thumbnails for a set of images._get_or_create_thumbnails_for_image: This method is used to get
or create thumbnails for a single image.Thanks to these methods, you can easily generate thumbnails for images
stored into odoo through three different ways:A relational field referencing record inheriting fromfs.image.relation.mixin.An odoo’s Image field.An FSImage field.The sizes of the thumbnails generated by these methods are configured
through the creation of a new record into these.thumbnail.sizemodel. This model allows you to define the size of thumbnails by search
engine backend, model and field. For example, you can define that you
want to generate thumbnails of size100x100for all the images
stored into theproduct.templatemodel and theimagefield when
you export them to theopensearch_xyzbackend. In this way, you can
easily define different thumbnail sizes for different search engine
backends, models and fields according to your needs.Thumbnails are always retrieved and generated for one image and a
specificbase_name. The base name is used as a key to identify the
thumbnails from an image related to a usage and also as base name for
the file name of the thumbnails generated. By default, thebase_nameis computed from the display name of the record that contains the image
to ensure a good SEO. To avoid problems with special characters, thebase_nameis normalized before being used.Here is an example of how to use these methods:fromodooimportmodels,fieldsfromodoo.addons.fs_imeage.fieldsimportFSImageclassProductImageRelation(models.Model):_name="product.image.relation"_inherit=["fs.image.relation.mixin"]name=fields.Char(required=True)product_id=fields.Many2one("product.product",required=True,ondelete="cascade",)classProductProduct(models.Model):_name="product.product"_inherit=["se.indexable.record","product.product"]name=fields.Char(required=True)image=fields.Image(required=True)image_ids=fields.One2many("product.image.relation","product_id",string="Images",)fs_image=FSImage(required=True)# A creation is always done for a given se.index record.index=self.env["se.index"].browse(1)product=self.env["product.product"].browse(1)# Get or create thumbnails for a single imagefor(thumbnail_size,thumbnail)inproduct._get_or_create_thumbnails_for_image(index,field_name="image",):# Do something with the thumbnailprint(f"Thumbnail  for image with size{thumbnail_size.display_name}""is available at url{thumbnail.image.url}")# Get or create thumbnails for a single imagefor(thumbnail_size,thumbnail)inproduct._get_or_create_thumbnails_for_image(index,field_name="fs_image",):# Do something with the thumbnailprint(f"Thumbnail for fs_image with size{thumbnail_size.display_name}""is available at url{thumbnail.image.url}")# Get or create thumbnails for a set of imagesthumbnails_by_image=product._get_or_create_thumbnails_for_multi_images(index,field_name="image_ids",)for(image,thumbnails)inthumbnails_by_image.items():for(thumbnail_size,thumbnail)inthumbnails:# Do something with the thumbnailprint(f"Thumbnail for image{image.name}with size ""{thumbnail_size.display_name}is available at url ""{thumbnail.image.url}")Bug TrackerBugs are tracked onGitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomedfeedback.Do not contact contributors directly about support or help with technical issues.CreditsAuthorsACSONE SA/NVContributorsLaurent Mignonlaurent.mignon@acsone.eu(https://www.acsone.eu/)Other creditsThe development of this module has been financially supported by:-Alcyon BeluxMaintainersThis module is maintained by the OCA.OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.Currentmaintainer:This module is part of theOCA/search-engineproject on GitHub.You are welcome to contribute. To learn how please visithttps://odoo-community.org/page/Contribute.