How do I get dimensions of an image SAPUI5?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have an image which is being set through:
var oImage = new sap.m.Image({
id: image0,
src: "img/image0.jpg"
});
I want to figure out the width and height of the image ?
I have tried oImage.getWidth()
and oImage.getHeight()
but those return empty. I have also tried parseInt(oImage.getWidth())
and parseInt(oImage.getHeight())
but those return NaN
.
sapui5
add a comment |
I have an image which is being set through:
var oImage = new sap.m.Image({
id: image0,
src: "img/image0.jpg"
});
I want to figure out the width and height of the image ?
I have tried oImage.getWidth()
and oImage.getHeight()
but those return empty. I have also tried parseInt(oImage.getWidth())
and parseInt(oImage.getHeight())
but those return NaN
.
sapui5
Make sure the image is init correctly. Then your oImage.getWidth() and oImage.getHeight() will work :)
– Ivan Kaloyanov
Jan 3 at 7:50
what do you mean that image is init correctly?
– Umar Abdullah
Jan 3 at 8:02
would you attack screenshot of your oImage object or atleast the output of console.log(oImage);
– Ivan Kaloyanov
Jan 3 at 8:07
I would like to know how to get the dimension of image.What steps / code i have to use.
– Umar Abdullah
Jan 3 at 8:10
Like I said oImage.getWidth() and oImage.getHeight() works as long as your object is sap.m.Image. openui5.hana.ondemand.com/#/api/sap.m.Image
– Ivan Kaloyanov
Jan 3 at 8:16
add a comment |
I have an image which is being set through:
var oImage = new sap.m.Image({
id: image0,
src: "img/image0.jpg"
});
I want to figure out the width and height of the image ?
I have tried oImage.getWidth()
and oImage.getHeight()
but those return empty. I have also tried parseInt(oImage.getWidth())
and parseInt(oImage.getHeight())
but those return NaN
.
sapui5
I have an image which is being set through:
var oImage = new sap.m.Image({
id: image0,
src: "img/image0.jpg"
});
I want to figure out the width and height of the image ?
I have tried oImage.getWidth()
and oImage.getHeight()
but those return empty. I have also tried parseInt(oImage.getWidth())
and parseInt(oImage.getHeight())
but those return NaN
.
sapui5
sapui5
edited Jan 3 at 8:01
Umar Abdullah
asked Jan 3 at 5:55
Umar AbdullahUmar Abdullah
717419
717419
Make sure the image is init correctly. Then your oImage.getWidth() and oImage.getHeight() will work :)
– Ivan Kaloyanov
Jan 3 at 7:50
what do you mean that image is init correctly?
– Umar Abdullah
Jan 3 at 8:02
would you attack screenshot of your oImage object or atleast the output of console.log(oImage);
– Ivan Kaloyanov
Jan 3 at 8:07
I would like to know how to get the dimension of image.What steps / code i have to use.
– Umar Abdullah
Jan 3 at 8:10
Like I said oImage.getWidth() and oImage.getHeight() works as long as your object is sap.m.Image. openui5.hana.ondemand.com/#/api/sap.m.Image
– Ivan Kaloyanov
Jan 3 at 8:16
add a comment |
Make sure the image is init correctly. Then your oImage.getWidth() and oImage.getHeight() will work :)
– Ivan Kaloyanov
Jan 3 at 7:50
what do you mean that image is init correctly?
– Umar Abdullah
Jan 3 at 8:02
would you attack screenshot of your oImage object or atleast the output of console.log(oImage);
– Ivan Kaloyanov
Jan 3 at 8:07
I would like to know how to get the dimension of image.What steps / code i have to use.
– Umar Abdullah
Jan 3 at 8:10
Like I said oImage.getWidth() and oImage.getHeight() works as long as your object is sap.m.Image. openui5.hana.ondemand.com/#/api/sap.m.Image
– Ivan Kaloyanov
Jan 3 at 8:16
Make sure the image is init correctly. Then your oImage.getWidth() and oImage.getHeight() will work :)
– Ivan Kaloyanov
Jan 3 at 7:50
Make sure the image is init correctly. Then your oImage.getWidth() and oImage.getHeight() will work :)
– Ivan Kaloyanov
Jan 3 at 7:50
what do you mean that image is init correctly?
– Umar Abdullah
Jan 3 at 8:02
what do you mean that image is init correctly?
– Umar Abdullah
Jan 3 at 8:02
would you attack screenshot of your oImage object or atleast the output of console.log(oImage);
– Ivan Kaloyanov
Jan 3 at 8:07
would you attack screenshot of your oImage object or atleast the output of console.log(oImage);
– Ivan Kaloyanov
Jan 3 at 8:07
I would like to know how to get the dimension of image.What steps / code i have to use.
– Umar Abdullah
Jan 3 at 8:10
I would like to know how to get the dimension of image.What steps / code i have to use.
– Umar Abdullah
Jan 3 at 8:10
Like I said oImage.getWidth() and oImage.getHeight() works as long as your object is sap.m.Image. openui5.hana.ondemand.com/#/api/sap.m.Image
– Ivan Kaloyanov
Jan 3 at 8:16
Like I said oImage.getWidth() and oImage.getHeight() works as long as your object is sap.m.Image. openui5.hana.ondemand.com/#/api/sap.m.Image
– Ivan Kaloyanov
Jan 3 at 8:16
add a comment |
2 Answers
2
active
oldest
votes
The values are empty because you haven't set them yet. Both getHeight
and getWidth
return the set values not the default height and width of the image. Have a look at Image Control.
var oImage = new sap.m.Image("image0", {
src: "img/load.gif",
height: "30vh",
width: "30vw"
});
This oImage.getWidth()
will return "30vw"
add a comment |
Since, you have not specified with and height of the image, you will have to use the DOM to get the details of the image. Try the following code in your controller:
var image = this.byId("image0");
var oDomRef = image.getDomRef()
console.log(oDomRef .width, oDomRef .height);
It will give the image width and height in px.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017019%2fhow-do-i-get-dimensions-of-an-image-sapui5%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The values are empty because you haven't set them yet. Both getHeight
and getWidth
return the set values not the default height and width of the image. Have a look at Image Control.
var oImage = new sap.m.Image("image0", {
src: "img/load.gif",
height: "30vh",
width: "30vw"
});
This oImage.getWidth()
will return "30vw"
add a comment |
The values are empty because you haven't set them yet. Both getHeight
and getWidth
return the set values not the default height and width of the image. Have a look at Image Control.
var oImage = new sap.m.Image("image0", {
src: "img/load.gif",
height: "30vh",
width: "30vw"
});
This oImage.getWidth()
will return "30vw"
add a comment |
The values are empty because you haven't set them yet. Both getHeight
and getWidth
return the set values not the default height and width of the image. Have a look at Image Control.
var oImage = new sap.m.Image("image0", {
src: "img/load.gif",
height: "30vh",
width: "30vw"
});
This oImage.getWidth()
will return "30vw"
The values are empty because you haven't set them yet. Both getHeight
and getWidth
return the set values not the default height and width of the image. Have a look at Image Control.
var oImage = new sap.m.Image("image0", {
src: "img/load.gif",
height: "30vh",
width: "30vw"
});
This oImage.getWidth()
will return "30vw"
var oImage = new sap.m.Image("image0", {
src: "img/load.gif",
height: "30vh",
width: "30vw"
});
var oImage = new sap.m.Image("image0", {
src: "img/load.gif",
height: "30vh",
width: "30vw"
});
edited Jan 4 at 8:22
answered Jan 4 at 8:13
O.OO.O
827422
827422
add a comment |
add a comment |
Since, you have not specified with and height of the image, you will have to use the DOM to get the details of the image. Try the following code in your controller:
var image = this.byId("image0");
var oDomRef = image.getDomRef()
console.log(oDomRef .width, oDomRef .height);
It will give the image width and height in px.
add a comment |
Since, you have not specified with and height of the image, you will have to use the DOM to get the details of the image. Try the following code in your controller:
var image = this.byId("image0");
var oDomRef = image.getDomRef()
console.log(oDomRef .width, oDomRef .height);
It will give the image width and height in px.
add a comment |
Since, you have not specified with and height of the image, you will have to use the DOM to get the details of the image. Try the following code in your controller:
var image = this.byId("image0");
var oDomRef = image.getDomRef()
console.log(oDomRef .width, oDomRef .height);
It will give the image width and height in px.
Since, you have not specified with and height of the image, you will have to use the DOM to get the details of the image. Try the following code in your controller:
var image = this.byId("image0");
var oDomRef = image.getDomRef()
console.log(oDomRef .width, oDomRef .height);
It will give the image width and height in px.
answered Jan 4 at 9:01
Rahul BhardwajRahul Bhardwaj
1,8331918
1,8331918
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017019%2fhow-do-i-get-dimensions-of-an-image-sapui5%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Make sure the image is init correctly. Then your oImage.getWidth() and oImage.getHeight() will work :)
– Ivan Kaloyanov
Jan 3 at 7:50
what do you mean that image is init correctly?
– Umar Abdullah
Jan 3 at 8:02
would you attack screenshot of your oImage object or atleast the output of console.log(oImage);
– Ivan Kaloyanov
Jan 3 at 8:07
I would like to know how to get the dimension of image.What steps / code i have to use.
– Umar Abdullah
Jan 3 at 8:10
Like I said oImage.getWidth() and oImage.getHeight() works as long as your object is sap.m.Image. openui5.hana.ondemand.com/#/api/sap.m.Image
– Ivan Kaloyanov
Jan 3 at 8:16