# Provide a simple responsive fotogrid using flex layout.
# Depends on the css/fotogrid.css defined styles.
def fotogrid(image_urls):
result = '
'
cols = 4
images = divmod(len(image_urls), cols)
images_per_col = images[0]
if images[1] > 0:
images_per_col += 1
nbr = 0
for img in image_urls:
if (nbr % images_per_col) == 0:
if nbr > 0:
result += '
' # closing fotocolumn
result += ''
result += '
'
nbr += 1
result += "
" # closing fotocolum, fotorow
return result