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

Feature/nonimage thumbnail #28

Merged
merged 9 commits into from
Jan 18, 2016
Merged

Feature/nonimage thumbnail #28

merged 9 commits into from
Jan 18, 2016

Conversation

choonkeat
Copy link
Owner

Sample rendering of png, pdf, xlsx and zip files

  • images are resized like normal behavior
  • pdf cover page is rendered as image, inside a polaroid, with the filename as caption
  • other files are rendered as text (stating the file extension), inside a polaroid, with the filename as caption
  • note that as per normal, attache returns the original file, unmodified, whenever we use original geometry string in the url

screen shot 2016-01-18 at 12 39 29 am

this behavior is useful in apps, since we can just upload files and use <img src=...> directly without special code.

- before Thread could exit, we may be already processing queue.pop
- this means, "threads.any?(&:alive?)" might return a misleading "true" and endless wait for "until queue.pop..."
- all non-image (including pdf; watch out #2) are rendered as a "polaroid"
- with filename as caption
@choonkeat choonkeat force-pushed the feature/nonimage_thumbnail branch 2 times, most recently from a8ba3ee to 6f6ec5d Compare January 18, 2016 07:06
@winston
Copy link

winston commented Jan 18, 2016

Some questions

filename as caption

What happens if the filename is long? Will the polaroid look ugly?

polaroid

From a design perspective, not sure if this is desirable, because then normal images are not polaroid-ed and doesn't have the shadow, while others are polaroid-ed and have the shadow. If I want to achieve consistency, then I can't really get rid of the shadow because it's already part of the image. Right?

PREVIEW_SIZE = ENV.fetch('PREVIEW_SIZE', '96x')

Also, the thumbnail size for non images are fixed? Meaning I can't specify it from <img src right?

@choonkeat
Copy link
Owner Author

What happens if the filename is long? Will the polaroid look ugly?

it wraps.
screen shot 2016-01-18 at 4 06 39 pm

From a design perspective, not sure if this is desirable, because then normal images are not polaroid-ed and doesn't have the shadow, while others are polaroid-ed and have the shadow. If I want to achieve consistency, then I can't really get rid of the shadow because it's already part of the image. Right?

Correct. I'd change it to a more minimal "file icon" look if I can just sort out the commands :-P otherwise, maybe i'll just introduce black/white border (it is ultimately still a styled image, albeit minimally so)

Also, the thumbnail size for non images are fixed? Meaning I can't specify it from <img src right?

Correct. Though the file extension icons wouldn't look good

- milder color
- fix border so pdf and other files have same width 132px
@choonkeat
Copy link
Owner Author

lighter colors, fixed difference of width between pdf and other file icons

screen shot 2016-01-18 at 9 35 51 pm

@winston
Copy link

winston commented Jan 18, 2016

👍

threads = lambdas.shuffle.collect { |code| Thread.new { queue << [Thread.current, code.call] } }
until (item = queue.pop).last do
thread, _ = item
thread.join # we could be popping `queue` before thread exited
Copy link
Owner Author

Choose a reason for hiding this comment

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

@winston note that this join fixes the problem of attache server hanging

  • in the Thread.new code above, we do queue << ... and then the thread exits
  • but the processing of queue.pop could happen before the thread exits
  • thus, break unless threads.any?(&:alive?) incorrectly account for the soon-to-be-exited thread
  • the fix is to explicitly join that thread, before we check threads.any?(&:alive?)

Copy link

Choose a reason for hiding this comment

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

choonkeat added a commit that referenced this pull request Jan 18, 2016
@choonkeat choonkeat merged commit 6e2cedb into master Jan 18, 2016
@choonkeat choonkeat deleted the feature/nonimage_thumbnail branch January 18, 2016 13:50
@choonkeat
Copy link
Owner Author

background: my own app uses the dynamic image/resizing features as well as the document/file storage features. when users upload documents alongside images, the resized images shows up nicely but document files are presented as icons.

@abitdodgy since your work revolves around just document and file storage, I was wondering if you'd care to chime in on such a feature (for an image server)

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

Successfully merging this pull request may close these issues.

2 participants