what is the correct way of using fromURL method? #9958
Answered
by
asturur
kapoor-codes
asked this question in
Q&A
-
Hi fam! I'm trying to add an image using fromURL method, unfortunately its a static method and I'm assuming it can't be accessed outside the class (with an instance), so what would be the correct way of calling this method: fabric.FabricImage.fromURL(
"https://fabricjs.com/logo.png",
{},
{
height: 100
}
); Declaration: /**
* Creates an instance of Image from an URL string
* @static
* @param {String} url URL to create an image from
* @param {LoadImageOptions} [options] Options object
* @returns {Promise<FabricImage>}
*/
static fromURL<T extends TOptions<ImageProps>>(
url: string,
{ crossOrigin = null, signal }: LoadImageOptions = {},
imageOptions?: T
): Promise<FabricImage> {
return loadImage(url, { crossOrigin, signal }).then(
(img) => new this(img, imageOptions)
);
} |
Beta Was this translation helpful? Give feedback.
Answered by
asturur
Jul 1, 2024
Replies: 1 comment 1 reply
-
This is how you use it. How else do you want to use it? const myFabricImageWithLogoPng = await fabric.FabricImage.fromURL(
"https://fabricjs.com/logo.png",
{},
{
height: 100
}
); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kapoor-codes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is how you use it. How else do you want to use it?