With the recent addition of search_embed iframes on other pages, we had photo cards appearing but the photo_clipboard module was not imported thus the checkboxes did nothing. I don't want to import photo_clipboard onto every single page, I'd rather they click through to the full search UI. Otherwise every single page will have the tray and often not a good enough reason for it. So, since the functionality of the checkbox is completely reliant on the photo_clipboard.js module anyway, there's no reason not to have it generated by that module.
		
			
				
	
	
		
			67 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| {# Specific extensions, then specific mimetypes, then general mimtypes #}
 | |
| {% set thumbnails =
 | |
|     {
 | |
|         "svg": "svg",
 | |
| 
 | |
|         "application/zip": "archive",
 | |
|         "application/x-tar": "archive",
 | |
| 
 | |
|         "archive": "archive",
 | |
|         "audio": "audio",
 | |
|         "image": "image",
 | |
|         "video": "video",
 | |
|         "text": "txt",
 | |
| 
 | |
|     }
 | |
| %}
 | |
| {% macro create_photo_card(photo, view="grid") %}
 | |
| {% set view = (view if view in ("list", "grid") else "grid") %}
 | |
| 
 | |
| {% set metadata_inner = "" %}
 | |
| {% if photo.width %}
 | |
|     {% set metadata_inner = "{m}{w}×{h}, ".format(m=metadata_inner, w=photo.width, h=photo.height) %}
 | |
| {% endif %}
 | |
| {% if photo.duration %}
 | |
|     {% set metadata_inner = "{m}{d}, ".format(m=metadata_inner, d=photo.duration_string) %}
 | |
| {% endif -%}
 | |
| 
 | |
| <div
 | |
|     data-id="{{photo.id}}"
 | |
|     class="photo_card photo_card_{{view}} photo_card_unselected {%if photo.searchhidden%}photo_card_searchhidden{%endif%}"
 | |
| >
 | |
|     <div class="photo_card_filename"><a target="_blank" href="/photo/{{photo.id}}">{{photo.basename}}</a></div>
 | |
|     <span class="photo_card_metadata">
 | |
|         {{- metadata_inner|safe -}}
 | |
|         <a target="_blank" href="{{photo|file_link}}">{{photo.bytestring}}</a>
 | |
|     </span>
 | |
| 
 | |
|     {% if view == "grid" %}
 | |
|     {% if photo.thumbnail %}
 | |
|         {% set thumbnail_src = "/thumbnail/" + photo.id + ".jpg" %}
 | |
|     {% else %}
 | |
|         {% set thumbnail_src =
 | |
|             thumbnails.get(photo.extension, "") or
 | |
|             thumbnails.get(photo.mimetype, "") or
 | |
|             thumbnails.get(photo.simple_mimetype, "") or
 | |
|             "other"
 | |
|         %}
 | |
|         {% set thumbnail_src = "/static/basic_thumbnails/" + thumbnail_src + ".png" %}
 | |
|     {% endif -%}
 | |
| 
 | |
|     {% set tag_names_title = [] %}
 | |
|     {% for tag in photo.get_tags() %}
 | |
|         {% do tag_names_title.append(tag.name) %}
 | |
|     {% endfor -%}
 | |
| 
 | |
|     {% set tag_names_title = ", ".join(tag_names_title) %}
 | |
|     {% if tag_names_title %}
 | |
|         {% set tag_names_inner = "T" %}
 | |
|     {% else %}
 | |
|         {% set tag_names_inner = "" %}
 | |
|     {% endif -%}
 | |
|     <a class="photo_card_thumbnail" target="_blank" href="/photo/{{photo.id}}"><img loading="lazy" src="{{thumbnail_src}}"></a>
 | |
|     <span class="photo_card_tags" title="{{tag_names_title}}">{{tag_names_inner}}</span>
 | |
|     {% endif %}
 | |
| </div>
 | |
| 
 | |
| {% endmacro %}
 |