jQuery plugin for transforming URLs to appropriate resource (image, link, YouTube, Vimeo video,...)
JavaScript
Latest commit 99113d4 Jan 22, 2014 @dejan update readme
Permalink
Failed to load latest commit information.
README.md
demo.html update demo Jan 20, 2014
jquery.auto_html.js add width option for image filter; fix options for youtube Jan 20, 2014

README.md

jquery.auto_html.js

jQuery port of Rails' extension auto_html

Example usage

Given this comment div:

<div class="comment">
http://gogreece2014.com/wp-content/uploads/2013/09/mykonos8.jpg

And you will go to Mykonos
With a vision of a gentle coast
And a sun to maybe dissipate
Shadows of the mess you made

http://www.youtube.com/watch?v=DT-dxG4WWf4
</div>

and this script:

<script type="text/javascript">
  $('.comment')
    .simpleFormat()
    .image()
    .youtube({width:500, height:400})
    .link();
</script>

The comment div will be transformed to this:

<p><img src="http://gogreece2014.com/wp-content/uploads/2013/09/mykonos8.jpg" alt="" width="500px"></p><p>And you will go to Mykonos<br>With a vision of a gentle coast<br>And a sun to maybe dissipate<br>Shadows of the mess you made</p><p><iframe class="youtube-player" type="text/html" width="500" height="400" src="http://www.youtube.com/embed/DT-dxG4WWf4" frameborder="0"></iframe>

Credits

Author: Dejan Simic