diff options
author | Karl <kc0bfv@gmail.com> | 2021-07-10 19:52:06 +0300 |
---|---|---|
committer | Karl <kc0bfv@gmail.com> | 2021-07-10 19:52:06 +0300 |
commit | 91e15316f64dfb3b1990299e9c2bdf442b4081aa (patch) | |
tree | 5d61b601e7a3d8e31ae1acd416362f868ff5dd9d | |
parent | e75c9c61a828d0d56b7d2ac2256e05b26c18697d (diff) | |
parent | 410af20133539767c33a91144ce1427ec0802665 (diff) |
Add feature to disable download button
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | assets/js/main.js | 19 | ||||
-rw-r--r-- | exampleSite/config.toml | 1 | ||||
-rw-r--r-- | exampleSiteNoAlbum/config.toml | 1 | ||||
-rw-r--r-- | layouts/partials/sect_and_img_content.html | 4 |
5 files changed, 17 insertions, 9 deletions
@@ -42,6 +42,7 @@ The `exampleSite` demonstrates the features unique to this theme. In your site * `column_count` - the number of columns in which to display images (default 2) * `breadcrumb_use_title` - if true, breadcrumbs (the path-like display at the bottom) will use page titles instead of paths * `filename_as_phototitle` - if true, a humanized form of the filename will be used as the phototitle (default false) +* `images_downloadable` - if true, images have a download button (default true) Additionally, `Author.name` and `Author.email` in the site config will display as the author and webmaster email. diff --git a/assets/js/main.js b/assets/js/main.js index c6d6410..6371eb6 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -293,16 +293,19 @@ type: "image", image: { titleSrc: function(item) { - let caption = '<div title="Download" ' + - 'class="download-button"><a href="' + - item.el.attr("href") + '" download="' + - item.el.attr("orig_name") + - '"><i class="fa fa-download"></i></a></div>' + - '<div class="caption-surround">'; - if( item.el.attr("phototitle") ) { + let caption = ''; + if(item.el.attr("downloadable") == "true"){ + caption += '<div title="Download" ' + + 'class="download-button"><a href="' + + item.el.attr("href") + '" download="' + + item.el.attr("orig_name") + + '"><i class="fa fa-download"></i></a></div>' + + '<div class="caption-surround">'; + } + if( item.el.attr("phototitle") != "" ) { caption += "<h2>" + item.el.attr("phototitle") + "</h2>"; } - if( item.el.attr("description") ) { + if( item.el.attr("description") != "" ) { caption += '<p class="description">' + item.el.attr("description") + "</p>"; } diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 2b0481a..5765357 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -23,6 +23,7 @@ disableKinds = ["taxonomy", "taxonomyTerm"] #column_count = 2 #breadcrumb_use_title = false #filename_as_phototitle = false + #images_downloadable = true # Headerbar links # Do not put too many links here, diff --git a/exampleSiteNoAlbum/config.toml b/exampleSiteNoAlbum/config.toml index ae1fc7e..4bf73d6 100644 --- a/exampleSiteNoAlbum/config.toml +++ b/exampleSiteNoAlbum/config.toml @@ -22,6 +22,7 @@ disableKinds = ["taxonomy", "taxonomyTerm"] #full_quality = 90 #column_count = 2 #filename_as_phototitle = false + #images_downloadable = true # Headerbar links # Do not put here too many links, diff --git a/layouts/partials/sect_and_img_content.html b/layouts/partials/sect_and_img_content.html index 8d9e06c..fca47bd 100644 --- a/layouts/partials/sect_and_img_content.html +++ b/layouts/partials/sect_and_img_content.html @@ -8,6 +8,7 @@ {{- $thumb_quality := default 50 ($.Param "thumb_quality") }} {{- $full_quality := default 90 ($.Param "full_quality") }} {{- $filename_as_phototitle := default false ($.Param "filename_as_phototitle") }} + {{- $downloadable := default true ($.Param "images_downloadable") }} {{- $thumb_size := printf "%dx q%d" $thumb_width $thumb_quality }} {{- $full_size := printf "%dx q%d" $full_width $full_quality }} @@ -149,8 +150,9 @@ {{- else }} <a class="gallery-item" phototitle="{{ .phototitle }}" description="{{ .description }}" - orig_name="{{ path.Base .image.Name }}" gallery_index="{{ .index }}" + downloadable="{{ cond $downloadable "true" "false" }}" + orig_name="{{ path.Base .image.Name }}" href="{{ .full.RelPermalink }}"> <img src="{{ .thumb.RelPermalink }}" {{ with .alt }} alt="{{ . }}"{{ end }}> |