Skip to content
jQuery plugin for transforming URLs to appropriate resource (image, link, YouTube, Vimeo video,...)
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.md
demo.html
jquery.auto_html.js

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

Something went wrong with that request. Please try again.