OdooWiki OCA HUB

Image URLs from HTML field

html_image_url_extractor folder_open OCA/server-tools open_in_new
Tools License: AGPL-3

This module includes a method that extracts image URLs from any chunk of HTML, in appearing order.

It is useful for modules such as website_blog_excerpt_img: blog list shows the first image included in the post if haven't a defined cover image.

auto_awesome What this module does

AI-generated from the code · Odoo 16.0

Adds a helper that pulls image addresses out of any HTML content in Odoo, in the order they appear. Other modules can use it to show the first image of a post or page when no cover image is set.

This module does not add any menu, screen or button. It extends the existing ir.fields.converter model with a new method, imgs_from_html, that other modules can call to read image addresses from a piece of HTML text.

The method scans the HTML and returns the image addresses one by one, in the order they appear. It finds images defined with an img element that has a src attribute, and also images set as a background through a style attribute using a background or background-image rule with a url value.

  • You can ask for only the first few images by giving a maximum number.
  • If the HTML cannot be parsed, the method either raises the error or simply logs it and returns nothing, depending on the option chosen by the caller.
  • Malformed style rules are ignored and only logged, so a broken style does not stop the extraction.

Because it only provides this utility, it changes nothing visible by itself. Its value appears when another module uses it, for example to display the first image found in a blog post when the post has no cover image defined.

Depends on

base

Required by other modules

Models and fields (1)
  • ir.fields.converter · extends an existing model

Text generated by AI (DeepSeek) from reading the Odoo 16.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 5 confirmed, 4 with no information of 9 versions.

Sources · Odoo 15.0

Confirmed on 2026-11-03 in branch 15.0 of OCA/server-tools.

terminal Installation and usage

OCA documentation · Odoo 16.0

This module just adds a technical utility, but nothing for the end user.

If you are a developer and need this utility for your module, see these examples and read the docs inside the code.

Python example:

@api.multi
def some_method(self):
    # Get images from an HTML field
    imgs = self.env["ir.fields.converter"].imgs_from_html(self.html_field)
    for url in imgs:
        # Do stuff with those URLs
        pass

QWeb example:

<t t-foreach="env['ir.fields.converter']
              .imgs_from_html(blog_post.content, 1)"
   t-as="url">
    <img t-att-href="url"/>
</t>

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.