innoq / statuses

statuses
Apache License 2.0
13 stars 14 forks source link

Add image preview #70

Closed aheusingfeld closed 9 years ago

aheusingfeld commented 9 years ago

The idea of this is to add JavaScript code to the page which iterates over all posts and check whether there is text in the post that matches a certain pattern. This pattern would match 1.) A URL prefixed with ! which is present anywhere in the post -> regex: "/!(http[^\s]+)/gi" 2.) A valid markdown image syntax like ![alternative text](http://my.url/great-image.gif) -> regex: "/!\[(.+)\]\((http[^\s]+)\)/gi" If a matching text is found, the code will append an tag to the post to render the (potential) image

Afterwards a link like !http://i.imgur.com/dAnMWxQ.gif should be converted to this :) yeeehaahhh

FND commented 9 years ago

Why the need for a ! prefix - couldn't we just do a HEAD request (server-side, to avoid cross-origin issues) for all each link as it is posted, determining the content type?

Also, sigh.

stilkov commented 9 years ago

That would render every image inline. Do we want this? I’m not sure I do.

FND commented 9 years ago

I'm also skeptical (thus the sigh) - but I guess it's worth a try? (We could always collapse images later, displaying them only on demand.)

aheusingfeld commented 9 years ago

@stilkov btw: the idea with the HEAD request was initially yours https://github.com/innoq/statuses/issues/47#issuecomment-24025589

phaus commented 9 years ago

best thing is to make it optional for the user... so the user has to opt-in for inline images. But inline images are distirbing during the text-flow... i had the issue with the chatlogs... decided to render the image, when the message is only the url of an image...

aheusingfeld commented 9 years ago

If at all for the JavaScript version, I'd go for a opt-out and write the property into the localStorage.

phaus commented 9 years ago

i would prefer going for an opt-in and write the property in the localStorage :-).

aheusingfeld commented 9 years ago

opt-in request moved to #79