Closed aheusingfeld closed 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.
That would render every image inline. Do we want this? I’m not sure I do.
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.)
@stilkov btw: the idea with the HEAD request was initially yours https://github.com/innoq/statuses/issues/47#issuecomment-24025589
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...
If at all for the JavaScript version, I'd go for a opt-out and write the property into the localStorage.
i would prefer going for an opt-in and write the property in the localStorage :-).
opt-in request moved to #79
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: "
tag to the post to render the (potential) image
/!(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 anAfterwards a link like![yeeehaahhh](http://i.imgur.com/dAnMWxQ.gif)
!http://i.imgur.com/dAnMWxQ.gif
should be converted to this :)