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

Thumbnail handling #71

Open
gianlucadelgobbo opened this issue Jun 21, 2016 · 6 comments
Open

Thumbnail handling #71

gianlucadelgobbo opened this issue Jun 21, 2016 · 6 comments

Comments

@gianlucadelgobbo
Copy link
Owner

there was a function that accordingly to the config was lookig for a size format if there wasnt he create it if there isnt the image was taking the default image.

@gianlucadelgobbo
Copy link
Owner Author

gianlucadelgobbo commented Jun 24, 2016

app/server/helper/media.js line 44
Almost done but the crop callback arrives when the image is still not available, solution?

@alappe
Copy link
Collaborator

alappe commented Jun 25, 2016

From a quick glance, the solution isn't that easy.

Since the imagemagick functions are are asynchronous, the getFileFormat function has to be async as well. Changing that is simple, but the usage seems to be inline in jade, and there we cannot use the resulting async function.

So one way would be to get the metadata and do cropping on upload, not on display.
The other way could be prepare all data such as this before the view is rendered, which would make the first view slow (since images will need to be resized).

@gianlucadelgobbo
Copy link
Owner Author

gianlucadelgobbo commented Jun 25, 2016

yes, server side could be very slow and we need to put a lot of code to make this check on every query in node, one single big event in node could have more then 1000 images, nested in different locations

Another solution could be a js client side for this very rare case

document.addEventListener('DOMContentLoaded', function () {
    var img = document.getElementById("img-#{result.permalink}");
    if (!img.complete || typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0) {
        img.src += "?" + new Date().getTime();
        console.log("reload");
    }
}, false);

Some more examples here
http://stackoverflow.com/questions/92720/jquery-javascript-to-replace-broken-images

@gianlucadelgobbo
Copy link
Owner Author

Formats are here, in every item of the sections
config/default.json

      "thumbnails": {
        "detail":{"w":1140,"h":641,"default":"event.jpg"},
        "list":{"w":263,"h":148,"default":"event.jpg"}
      }

@stefanisak
Copy link
Contributor

IMHO we should store the original file on upload and resize it later based on configuration. Resizing during upload solves the performance/async issue, but makes it hard to adjust the layout once different dimensions are required.

I'll try to find a solution based on your configs and @alappe suggests and come back here.

@gianlucadelgobbo
Copy link
Owner Author

For sure we do it in upload, but this is just for safety reason, noo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants