-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download images #12
Comments
@mapeal2 , Unfortunately i'm not sure about that. When you upload your images to Odoo it converts them into Base64 format, and this is the way they are stored in the database. I believe you would need to create an extension to extend the default image widget to allow for display of the content in your preferred file format (eg. JPG). As this is related to Odoo core functionality and not the module directly i'd recommend posting this question to help.odoo.com with a detailed description of what you would like to achieve. This way you will be able to pose the question to those more knowledgeable than me in regards to that particular widget. Please provide me with a link once you create the forum post. I'll follow the post and provide an answer if I come across a workable method in the future. |
The Multi Image module that Serpent developed support image preview and can be downloaded as jpg original. I use it on OpenERP 7.0 version. Works like a charm. Not sure if that can be a help for the module develop. https://code.launchpad.net/~serpentcs/openerp-web/multi-image-7.0 |
@frankmiao2015 , Thanks for the link. I've taken a look and it seems that the multi-image-7.0 module has support for storing the images in the local filestore rather than the database. Here's the code: Basically the module bypasses the database for the image store, so your images are still left in their original upload format and are stored in: /web/static/src/img/image_multi/{{your file name here}} I will label this as a feature request and look into adding this functionality at a later date when I can commit the required time to build it. |
Hi, I've posted the question on the forum: https://www.odoo.com/forum/help-1/question/download-binary-files-with-original-format-72297 I guess the solution has to be found somewhere in the attachments functionality, since the attachments are uploaded in binary format as well, but downloaded in the original format. Regards, |
@mapeal2 , thanks, i've subscribed to the forum post. I'll keep digging through the source code until I can find a solution. I'll leave this issue open as a feature request until it has been implemented. Please also note i've moved the synced sliders over to Slick Slider for now as it has much of the same features and is a more active project: https://github.com/kenwheeler/slick I will add a menu in the backend for choosing sliders, and adding slider options in an update soon. Thanks for the suggestions! |
Hi @lukebranch, I've been investigating how to download binary files in the original format, and after realizing that attachments are stored in the file system with the purpose of leveraging the size of the database, I wonder now if it's more convenient to upload images as attachments instead of binary files. This has the following advantages from my humble point of view:
Please let me know what you think about my suggestions. Regards, |
As well as I know, Odoo can store the attachments in local files rather than database. You can config it by Settings->Technical->Parameters-System parameters. Change ir_attachment.location to file:///filestore, then your attachments would stock in the openerp/filestore folder. But your idea adding Published button for front download is great idea. Regards Frank |
Hi Frank, I've double checked that, as per default, attachments are stored in the file system instead of the database. From ir_attachment.py (https://github.com/odoo/odoo/blob/8.0/openerp/addons/base/ir/ir_attachment.py): "The 'data' function field (_data_get,data_set) is implemented using I'm trying to point out that it's maybe more convenient to follow the attachments philosophy of storing product images in the file system rather than in the database as binary files, in order to avoid further performance issues if the number/size of the images grow (which is likely to be like that). Furthermore, I've seen there's another addon planned to be developed in this repository (website_product_attachments) and I was thinking if both images and product documents are uploaded as attachments, they can be distinguished by the extension of the file or even a new field on the attachments form to determine where the attachment must be included (documents or images). On the product form, 2 new buttons can be created to open separately image attachments or document attachments, similarly to how it's done with projects. These buttons would open the attachment kanban view which displays a preview of the images, and from there the standard/extended attachment functionality can be used. On the website side, images and documents could be splitted using the same criteria, and displayed via different templates (carousel template or attachments template). I thought it was worth pointing out. If I didn't explain myself properly please let me know. Regards, |
@mapeal2 @frankmiao2015 , Thanks for all your feedback and ideas. I have been considering whether or not to keep the pictures in the database for a number of reasons, having them stored in the file system in their original format should theoretically allow people to use server-side optimisation for images like ngx_pagespeed among other things, while having them stored in the database allows for easier backups, scaleability and optimisations on image dimensions, on the fly in python (eg. serving a different image for retina/2x screens). Both have their pros and cons, so I may provide both as options and allow for people to choose to switch between one or the other in the admin backend:
I will look into implementing the database option first as the basic framework is already there, and will work on implementing the second option once I can find some time. Please feel free to suggest more features/ideas and i'll work on implementing them as soon as possible. |
Thanks @lukebranch ! |
@lukebranch |
And another one: |
Hi, just wanted to point out that the last issue you linked has a pull request associated that fixes the file name issue: odoo/odoo#1241 Still not merged, alas, but you can apply the patch by saving it on a text file and doing |
Thanks for the update. I'll take a look at patching this on a development instance and look forward to this being patched further upstream. |
Sorry for not replying on this thread, I have been very busy recently with other projects. I plan to work on this project heavily as soon as I can find time, as there are a number of features that i'd like to implement from suggestions from the community. |
I'm not sure I understand what odoo/odoo#1239 is referring to and how it's related to this request. I guess I need a better example to understand and reproduce it. In any case, what I can tell you is binary downloads with file names work in form views. They worked in 7, and they seem to work the same way in 8. Binary downloads in list/tree views (inside a form at least) are borked, though. They work, but they behave differently than in form views, and, if possible, should probably be re-worked to behave more like they do in form views. (They download all the data and "attach" it as a local download link with a generic mimetype and what ends up being an incomprehensible download file name. The filename is there in the link, but the download doesn't use that info.) Even if they fixed the file name and mimetype issues, it really shouldn't download all the attachments in the list. IMO, they should behave the same way they do in form views. So, until they fix that, this would be my recommendation (for binary field storage):
Other possible alternatives, which I haven't explored, are adding a button that triggers a download, a custom widget, or qweb template. But, I would save those for another time, when you feel like diving a little deeper and experimenting with it. Anyways, good work so far! |
Thanks for the suggestions, i'll definitely look into implementing the ideas in some form. Currently I am waiting for another module being ported to 8.0 from the OCA called product_images which handles multiple product images related to a product very nicely and allows for storage in filesystem, database, or external link, and generally handles the whole multi-image storage for products far better than this module's framework. I plan to use this (product_images) module as a basis for storing the product images, and will then re-write my module to pull the images from the one2many in this module. With the option to store images in the filesystem this will improve performance and allow for more flexible/interesting caching solutions and better handling for CDN's. Currently I do not have much time to work on it due to other commitments, however I will start work on this module again after the product_images module has been fully ported to 8.0 and is available in the OCA repository here: https://github.com/OCA/product-attribute You can track the progress here: and here: |
Hi Luke,
How can the images be downloaded in the original format? they're downloaded in binary format as of now.
Thanks in advance,
Manuel.
The text was updated successfully, but these errors were encountered: