Reputation: 2687
This is quite a project-specific question, to do with my implementation of svg-edit..
I've implemented the updated 'ext-server_opensave.js' (from this issue) so that the user is able to upload raster images from their file system.
The code snippet I'm having an issue with from 'ext-server_opensave.js' is the following:
function importImage(url) {
var newImage = svgCanvas.addSvgElementFromJson({
"element": "image",
"attr": {
"x": 0,
"y": 0,
"width": 0,
"height": 0,
"id": svgCanvas.getNextId(),
"style": "pointer-events:inherit"
}
});
svgCanvas.clearSelection();
svgCanvas.addToSelection([newImage]);
svgCanvas.setImageURL(url);
}
The width and height attributes don't work when setting them there, the other attributes do work. It's a weird bug - the first image upload uploads the file in its original size, then every subsequent image upload resizes to 48x48. If I set the width and height values in that method I pasted above, I see the image in those dimensions for a split second and then it resizes back to 48x48. Basically, there's some handler/method down the chain that is resizing the image after svgCanvas.addSvgElementFromJson
and svgCanvas.addToSelection
, and I can't figure out where, after hours of debugging the javascript.
Upvotes: 0
Views: 320
Reputation: 72385
Just a wild shot, but perhaps adding at line 128...
case 'import_img':
svgCanvas.setGoodImage(str64);
importImage(str64);
break;
setGoodImage()
sets the default image size when inserting new images. The 48x48 size you are seeing is the size of the SVG Edit's logo.
Upvotes: 0