diff --git a/setup.py b/setup.py
index ce3af4e7..09e28431 100644
--- a/setup.py
+++ b/setup.py
@@ -78,6 +78,9 @@ requires = [
'waitress', # 0.8.1
'WebHelpers', # 1.3
'zope.sqlalchemy', # 0.7
+
+ # This is used to obtain POD image dimensions.
+ 'PIL', # 1.1.7
]
diff --git a/tailbone/templates/products/read.mako b/tailbone/templates/products/read.mako
index 5bf6d296..690f9300 100644
--- a/tailbone/templates/products/read.mako
+++ b/tailbone/templates/products/read.mako
@@ -1,6 +1,27 @@
<%inherit file="/products/crud.mako" />
-${parent.body()}
+<%def name="head_tags()">
+ ${parent.head_tags()}
+
+%def>
+
+
+
+
+ ${form.render()|n}
+
+ % if image:
+ ${h.image(image_url, u"Product Image", id='product-image', path=image_path, use_pil=True)}
+ % endif
+
<% product = form.fieldset.model %>
diff --git a/tailbone/views/products.py b/tailbone/views/products.py
index a6f1715f..8f59d879 100644
--- a/tailbone/views/products.py
+++ b/tailbone/views/products.py
@@ -26,6 +26,8 @@
Product Views
"""
+import os
+
from sqlalchemy import and_
from sqlalchemy.orm import joinedload, aliased
@@ -48,6 +50,7 @@ from rattail.db.model import (
Brand, Vendor, Department, Subdepartment, LabelProfile)
from rattail.gpc import GPC
from rattail.db.api import get_product_by_upc
+from rattail.pod import get_image_url, get_image_path
from ..db import Session
from ..forms import GPCFieldRenderer, BrandFieldRenderer, PriceFieldRenderer
@@ -264,6 +267,18 @@ class ProductCrud(CrudView):
del fs.current_price
return fs
+ def template_kwargs(self, form):
+ kwargs = {'image': False}
+ product = form.fieldset.model
+ if product.upc:
+ kwargs['image_url'] = get_image_url(
+ self.request.rattail_config, product.upc)
+ kwargs['image_path'] = get_image_path(
+ self.request.rattail_config, product.upc)
+ if os.path.exists(kwargs['image_path']):
+ kwargs['image'] = True
+ return kwargs
+
def products_search(request):
"""