1. create a file browser item on your page and add the below code into the post text section:
2. Create a dynamic action, Event:- Change
Selection Type:- Item
Event:- Change
Item:- Browse File Item
Action type :- Exectue Javascript Code
var canvas = $x('image-preview');
var ctx = canvas.getContext('2d');
var img = new Image;
img.src = window.URL.createObjectURL(this.triggeringElement.files[0]);
img.onload = function() {
if (img.width > 200) {
canvas.style.width = "50px";
}
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0);
$("#container-img-preview").show();
}
3. Resize Picture -HTML code
canvas#image-preview{
text-align: center;
margin-left: 100px;
margin-top: 30px;
border: 1px solid black;
width: 240px !important;
}
Comments
Post a Comment