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

Help with EXIF data plugin #1009

Closed
andrewboni opened this issue Jan 26, 2015 · 5 comments
Closed

Help with EXIF data plugin #1009

andrewboni opened this issue Jan 26, 2015 · 5 comments
Labels
feature-request question Needs help in usage

Comments

@andrewboni
Copy link

Hi, I'm in the process of writing a plugin to display EXIF information from a photo, for things like camera make, model, focal length, shutter speed, aperture, ISO, etc.

I'm using the gm-exif node plugin, which makes getting EXIF data easy.

I can extract the EXIF data successfully, but the plugin returns nothing, as it's presumably not waiting for the async exif() task. How can I fix this, so that the plugin waits for the EXIF data to be extracted?

Sample plugin usage:

{% exifinfo 2015-01-25-luchadors-in-the-mission/luchadors.jpg %}

Plugin code:

hexo.extend.tag.register('exifinfo', function(args){
    var exif = require('gm-exif');
    var imagePath = args[0];
    exif(imagePath, function(err, exifData) {
        return '<p>' + exifData.Make + ' ' + exifData.Model + ' | ' + exifData.FocalLength +'mm | ' + exifData.ExposureTime + 'sec exposure | ƒ/' + exifData.FNumber + ' | ' + 'ISO' + exifData.ISOSpeedRatings + '</p>';
    });
});
@tommy351
Copy link
Member

You can't do async task in tag plugins because Swig render files synchronously.

@tommy351 tommy351 added the question Needs help in usage label Jan 26, 2015
@andrewboni
Copy link
Author

Got it- makes sense. Can you point me in the right direction of how I might
be able to implement EXIF data reading functionality then? Thanks!

On Sun, Jan 25, 2015 at 8:36 PM, Tommy Chen notifications@github.com
wrote:

You can't do async task in tag plugins because Swig render files
synchronously.


Reply to this email directly or view it on GitHub.

@tommy351
Copy link
Member

You can try to write a filter. But it's more difficult. I'm thinking whether to replace Swig with Nunjucks which supports async rendering.

@andrewboni
Copy link
Author

I see okay- yes, I'm all in favor of async support

@tommy351
Copy link
Member

You can use async tag plugins since Hexo 3.

https://github.com/hexojs/hexo/wiki/Breaking-Changes-in-Hexo-3.0#async-tag-plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request question Needs help in usage
Projects
None yet
Development

No branches or pull requests

2 participants