Handle image map portlet without reference
authorThierry Florac <tflorac@ulthar.net>
Fri, 18 Oct 2019 16:52:14 +0200
changeset 497 7269f354c302
parent 496 e57576eb87a4
child 498 71a595c9a985
Handle image map portlet without reference
src/pyams_default_theme/shared/imagemap/portlet/templates/imagemap-default.pt
--- a/src/pyams_default_theme/shared/imagemap/portlet/templates/imagemap-default.pt	Fri Oct 18 15:26:42 2019 +0200
+++ b/src/pyams_default_theme/shared/imagemap/portlet/templates/imagemap-default.pt	Fri Oct 18 16:52:14 2019 +0200
@@ -3,29 +3,31 @@
 				 imagemap settings.target;">
 	<h2 tal:define="title i18n:settings.title"
 		tal:condition="title">${title}</h2>
-	<div class="wrapper-imagemap"
-		 tal:define="image i18n:imagemap.image;"
-		 tal:condition="image">
-		<img src="${tales:absolute_url(image)}" alt="" />
-		<svg version="1.1"
-			 xmlns="http://www.w3.org/2000/svg"
-			 xmlns:xlink="http://www.w3.org/1999/xlink"
-			 class="imagemap-areas"
-			 tal:define="size image.get_image_size()"
-			 viewBox="0 0 ${size[0]} ${size[1]}">
-			<tal:loop repeat="area imagemap.areas.values()">
-				<tal:var define="item imagemap.get_association(area)"
-						 condition="item and item.visible">
-					<a tal:define="info view.get_item_info(item);
-								   area_title i18n:area.title;
-								   item_title i18n:info.user_title;
-								   title area_title or item_title;"
-					   xlink:href="${item.get_url(request)}"
-					   xlink:title="${title}">
-						<polygon points="${area.svg_points}" />
-					</a>
-				</tal:var>
-			</tal:loop>
-		</svg>
-	</div>
+	<tal:if condition="imagemap is not None">
+		<div class="wrapper-imagemap"
+			 tal:define="image i18n:imagemap.image;"
+			 tal:condition="image">
+			<img src="${tales:absolute_url(image)}" alt="" />
+			<svg version="1.1"
+				 xmlns="http://www.w3.org/2000/svg"
+				 xmlns:xlink="http://www.w3.org/1999/xlink"
+				 class="imagemap-areas"
+				 tal:define="size image.get_image_size()"
+				 viewBox="0 0 ${size[0]} ${size[1]}">
+				<tal:loop repeat="area imagemap.areas.values()">
+					<tal:var define="item imagemap.get_association(area)"
+							 condition="item and item.visible">
+						<a tal:define="info view.get_item_info(item);
+									   area_title i18n:area.title;
+									   item_title i18n:info.user_title;
+									   title area_title or item_title;"
+						   xlink:href="${item.get_url(request)}"
+						   xlink:title="${title}">
+							<polygon points="${area.svg_points}" />
+						</a>
+					</tal:var>
+				</tal:loop>
+			</svg>
+		</div>
+	</tal:if>
 </div>