Resizeable Images jQueryUI
HTML
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<h1>HTML</h1>
<div id="html-preview" name="html-preview" contenteditable="true">
<p>Click here</p>
press the insertImage Button below to add an image
</div>
<br>
<button id='toggle-bold'>BOLD</button>
<button id='insertImage'>insertImage</button>
<br><br>
<!-- static added image -->
<img class='resizeable' id='myImg' src='http://imperavi.com/img/library.jpg' />
CSS
#resizeable {
width:250px;
height:100px;
background-color: #dadada;
}
.resizeable {
width: 200px; /*default width*/
float: left;
}
JavaScript
$(document).ready(function() {
$(document).on('click', '#toggle-bold', function(){
console.log('click')
document.execCommand('bold', false, null)
})
$(document).on('click', '#inset-text', function(){
console.log('inset-text')
document.execCommand('insertText', false, '<b>cool</b>')
})
$(document).on('click', '#insertImage', function(){
document.execCommand('insertHTML', false,
"<div><img class='resizeable' id='myImg' src='http://imperavi.com/img/library.jpg'></div>");
$(".resizeable").resizable({aspectRatio:true}); //just a try here
})
$(".resizeable").resizable({aspectRatio:true})
});