How to change height and width of an image

Hi, Im trying to change the height and width of an image and can’t seem to find the syntax
What I image it would look it :

$w(“#image”).height = 50;
$w(" #image ").width = 50;

Hi,
At this moment there’s no Wixcode API to set image dimensions.
Roi.

Hello,

Do you know when this will be possible?

I need to have a responsive vector image, so i’m trying to modify the width depend on page width because Band do not support vector image.

Do you know an alternative solution to my problem?

Thanks,
Tom

@tombeyers Since we’re talking about svg’s it may already be possible in Wix Tom.

I’d recommend these posts:

Let me know if you get this working!

Hello @skmedia ,

Thank you for your response. :slight_smile:

I tried to use XML string with my .svg file but it did not work.

I will publish a comment at https://www.wix.com/code/home/forum/wix-tips-and-updates/new-feature-opened-svg-o-o for not trouble this post.

Thanks,
Tom

The XML way of coding a SVG image seemed to work for me:

'<svg width="100" height="100"><rect width="100" height="100" style="fill:rgb(255,255,0)" /></svg>'

The first “width” (let’s call it WIDTH1) and “height” (HEIGHT1) should remain “100” and define the maximum shape size the SVG can be. In the Wix Editor the SVG should also cover the full area (let’s call it AREA1) of where the SVG can be.

The second “width” (WIDTH2) and “height” (HEIGHT2) define what part of AREA1 you want to be filled. You should view it as a percentage of WIDTH1 and HEIGHT1.

For example:
WIDTH1 = 100
HEIGHT1 = 100
WIDTH2 = 50
HEIGHT2 = 100

Result → half AREA 1 is filled with you desired color

You can also add variables to the XML code by breaking the code in two parts:

var yournumber = 46
var yoursvg = "#vectorImage1" //YOUR SVG IMAGE ID

var svgchange = $w(yoursvg).src = '<svg width="100" height="100"><rect width="' + yournumber + '" height="100" style="fill:rgb(255,255,0)" /></svg>'