Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make EXIF data displayed configurable #44

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ social_urls:
dribbble: "https://dribbble.com/rampatra"
linkedin: "https://in.linkedin.com/in/ram-patra"
github: "https://www.github.com/rampatra"

# Config which exif data to display
# Tag is the actual exif tag, icon is a fontawesome icon. Use JSON notation without line breaks
exif_display: '[{"tag": "Model", "icon": "camera-retro"}, {"tag": "FNumber", "icon": "dot-circle-o"}, {"tag": "ExposureTime", "icon": "clock-o"}, {"tag": "ISOSpeedRatings", "icon": "info-circle"}]'
Copy link
Owner

@rampatra rampatra Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a better name would be exif_tags instead of exif_display.

42 changes: 7 additions & 35 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,46 +307,18 @@
});

function getExifDataMarkup(img) {
var exif = fetchExifData(img);
var exif_display = $('#main').data('exif-display');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

var template = '';
for (var info in exif) {
if (info === "model") {
template += '<i class="fa fa-camera-retro" aria-hidden="true"></i> ' + exif["model"] + '&nbsp;&nbsp;';
}
if (info === "aperture") {
template += '<i class="fa fa-dot-circle-o" aria-hidden="true"></i> f/' + exif["aperture"] + '&nbsp;&nbsp;';
}
if (info === "shutter_speed") {
template += '<i class="fa fa-clock-o" aria-hidden="true"></i> ' + exif["shutter_speed"] + '&nbsp;&nbsp;';
}
if (info === "iso") {
template += '<i class="fa fa-info-circle" aria-hidden="true"></i> ' + exif["iso"] + '&nbsp;&nbsp;';
for (var current in exif_display) {
var current_data = exif_display[current];
var exif = EXIF.getTag(img, current_data['tag']);
if (typeof exif !== "undefined") {
template += '<i class="fa fa-' + current_data['icon'] + '" aria-hidden="true"></i> ' + exif + '&nbsp;&nbsp;';
}
}
return template;
}

function fetchExifData(img) {
var exifData = {};

if (EXIF.getTag(img, "Model") !== undefined) {
exifData.model = EXIF.getTag(img, "Model");
}

if (EXIF.getTag(img, "FNumber") !== undefined) {
exifData.aperture = EXIF.getTag(img, "FNumber");
}

if (EXIF.getTag(img, "ExposureTime") !== undefined) {
exifData.shutter_speed = EXIF.getTag(img, "ExposureTime");
}

if (EXIF.getTag(img, "ISOSpeedRatings") !== undefined) {
exifData.iso = EXIF.getTag(img, "ISOSpeedRatings");
}
return exifData;
}

});

})(jQuery);
})(jQuery);
2 changes: 1 addition & 1 deletion assets/js/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1><a href="index.html"><strong>{{ site.header.title }}</strong> {{ site.header
</header>

<!-- Main -->
<div id="main">
<div id="main" data-exif-display='{{ site.exif_display }}'>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

{% for image in site.static_files %}
{% if image.path contains 'fulls' %}
<article class="thumb">
Expand Down