Community mailing list archives

community@mail.odoo.com

Re: How to determine the url of a product image ?

by
Hieu Nguyen
- 10/27/2015 21:02:44
Thanks, Bruno for the tip.

`/website/image/product.template/#{product.id}/image{{'' if product_image_big else '/300x300' }}` doesn't work for me. Maybe, it's because I'm using Odoo 9.

In Odoo 9, `/website/image/product.template/{product.id}/image` actually works. So in my case, by knowing a product id, I can figure out the image url by replacing `{product.id}` with the id.

Thankfully,
Hieu

On 27/10/2015 22:37, Bruno Figares wrote:
<blockquote cite="mid:CADKQygKJjDjPTY-8eW_w4xTBHUJNNMimaMDivUh4TsHwxN_19w@mail.gmail.com" type="cite">
is this of any use to you?

<img itemprop="image" class="img img-responsive" t-attf-src="/website/image/product.template/#{product.id}/image{{'' if product_image_big else '/300x300' }}"/>

This is extracted from the product template in website_sale. Next step would be to look in the controller that serves that URL, and you can find that in website/controllers/main.py. look for '/website/image'.

Best regards,



On Tue, Oct 27, 2015 at 11:08 AM, Luke Branch <odoocommunitywidgets@gmail.com> wrote:
Hi Hieu,

I'm also interested in this but for version 8. I assume a similar method applies for both 8/9.

I need to be able to export the product.product.image URL into a CSV file to be used in Aeroo reports to allow me to create a hyperlink on a product image in a report that points back to the URL of the image on the website.

I have searched for quite a while for a solution for this, but still haven't figured it out yet. I'll post back here if I find anything, however if you find a solution please share it here, as I would be very interested in knowing how you did it.

On Tue, Oct 27, 2015 at 7:34 PM, Hieu Nguyen <hieutngn@gmail.com> wrote:
Hi everyone,

As I understand, product images are either stored in as binary in the Odoo database or filestore in Odoo 9.
When we use a template like below, Odoo will provide the the correct link to the image, so the web page and the product image will rendered correctly on browsers.
                <span itemprop="image" t-field="product.image" t-field-options='{"widget": "image", "class": "product_detail_img", "alt-field": "name"}'/>

Is there a way to determine a product image url, for example: `/web/image/product.template/534/image?unique=68b87dc` in python code?

I'm writing a module to generate a list of products and their corresponding image links and save it in a text file.

Thankfully,
Hieu


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe