Changed CSS grid layout for a table layout.
This commit is contained in:
@@ -23,13 +23,27 @@ def gallery_view(request, path = None):
|
||||
The path should be inside the GALLERY_ROOT path, otherwise a 404 error will be thrown.
|
||||
"""
|
||||
|
||||
def list2rows(lst, cells = 5):
|
||||
rows = []
|
||||
i = 0
|
||||
while i < len(lst):
|
||||
row = []
|
||||
for c in range(cells):
|
||||
try:
|
||||
row.append(lst[i + c])
|
||||
except:
|
||||
pass
|
||||
rows.append(row)
|
||||
i += cells
|
||||
return rows
|
||||
|
||||
full_path = settings.GALLERY_ROOT.joinpath(path) if path is not None else settings.GALLERY_ROOT
|
||||
|
||||
if full_path.exists():
|
||||
if full_path.is_dir():
|
||||
subdirs = sorted([i for i in full_path.iterdir() if i.is_dir()])
|
||||
images = sorted([i for i in full_path.iterdir() if i.is_file() and filetype.is_image(str(i))])
|
||||
display_images = []
|
||||
subdirs = sorted([i for i in full_path.iterdir() if i.is_dir()])
|
||||
images = sorted([i for i in full_path.iterdir() if i.is_file() and filetype.is_image(str(i))])
|
||||
img_data = []
|
||||
|
||||
for image in images:
|
||||
make_thumbnail(image)
|
||||
@@ -40,12 +54,12 @@ def gallery_view(request, path = None):
|
||||
'thumbnail': '/thumbs/' + path + '/' + image.name if path is not None else '/thumbs/' + image.name
|
||||
}
|
||||
|
||||
display_images.append(img_context)
|
||||
img_data.append(img_context)
|
||||
|
||||
context = {
|
||||
'path': path,
|
||||
'subdirs': subdirs,
|
||||
'images': display_images
|
||||
'subdirs': list2rows(subdirs),
|
||||
'images': list2rows(img_data)
|
||||
}
|
||||
|
||||
return render(request, 'gallery_view.html', context)
|
||||
|
Reference in New Issue
Block a user