Commit 8fc24c2d authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_corporate_identity&test: method maybe in link

parent 420b52ac
......@@ -47,17 +47,27 @@ if not img_src.lower().startswith("http"):
#END user ignoring guidelines
if img_src[0] == '/':
img_src = img_src[1:]
img_obj = context.restrictedTraverse(img_src.split("?")[0], None)
real_img_src = img_src.split("?")[0]
img_obj = context.restrictedTraverse(real_img_src, None)
# flag broken link until further notice
if img_obj is None:
return '<p style="color:red">The following image could not be found in erp5 OR is not following guidelines for links (eg no ./ prefix): <span style="font-weight:bold">%s</span></p>' % (img_src.split("?")[0])
return '<p style="color:red">The following image could not be found in erp5 OR is not following guidelines for links (eg no ./ prefix): <span style="font-weight:bold">%s</span></p>' % (real_img_src)
# img_src = "image_module/3/getData"
try:
img_type = img_obj.getContentType()
except AttributeError:
real_img_src = '/'.join(real_img_src.split('/')[:-1])
# img_obj is surely not None
img_obj = context.restrictedTraverse(real_img_src, None)
img_type = img_obj.getContentType()
# ensure alt attributes are set
if img_string.find('alt=') == -1:
img_string.replace ("src=", 'alt="%s" src=' % img_caption or img_obj.getTitle())
img_type = img_obj.getContentType()
# force svg display as svg or png
if img_type == "image/svg+xml":
if img_svg_format == "png":
......
......@@ -160,6 +160,10 @@ class TestCorporateIdentityMethod(ERP5TypeTestCase):
output_string = web_page.WebPage_validateImage(img_string=img_string)
self.assertEqual(output_string, '<img src="Template.Test.Image.Map?version=1&amp;format=">')
img_string = '<img src="Template.Test.Image.Map/getData">'
output_string = web_page.WebPage_validateImage(img_string=img_string)
self.assertEqual(output_string, '<img src="Template.Test.Image.Map/getData?format=">')
img_string = '<img src="./Template.Test.Image.Map?version=1">'
output_string = web_page.WebPage_validateImage(img_string=img_string)
self.assertEqual(output_string, '<img src="Template.Test.Image.Map?version=1&amp;format=">')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment