[openstack-dev] Display images/icon in Horizon Tables

Dave Johnston Dave.Johnston at owmobility.com
Thu Mar 20 16:43:13 UTC 2014


That worked perfectly.

I defined a method like this:

def get_image_url(stack):
    template_name = 'openwave/stack_catalogue/_icon.html'
    context = {"stack" : stack }
    return template.loader.render_to_string(template_name, context)

Stack is my class that has a field called image_icon.

With in the _icon.html template, I simply wrote:
<img src="{{stack.image_icon}}"  alt="Application Icon" height="42" width="42">

From: Lyle, David <david.lyle at hp.com>
Sent: 20 March 2014 15:45
To: OpenStack Development Mailing List (not for usage questions)
Subject: Re: [openstack-dev] Display images/icon in Horizon Tables

This is easy to accomplish by creating a custom template for a cell.  In your table, instead of providing a data field for the column, provide a method name, have that method load a custom HTML template.

Here is an example of this without an image of this method: https://github.com/openstack/horizon/blob/master/openstack_dashboard/dashboards/project/instances/tables.py#L653

But adding an <img> in the HTML template works fine.


From: Dave Johnston [mailto:Dave.Johnston at owmobility.com]
Sent: Thursday, March 20, 2014 9:20 AM
To: openstack-dev at lists.openstack.org
Subject: [openstack-dev] Display images/icon in Horizon Tables


I'm creating a custom panel for horizon.  I have developed a table that displays some information, and I would like to add a 'icon' to each row.
Ideally, I want to be able to specify the URL of a remote image, and have it displayed using the <img> tag.

Can this be acheived with filters, or some other mechanism ?

OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org

More information about the OpenStack-dev mailing list