Back

How Do i get a image to display on my website using the avatar/storage SDK on web

  • 0
  • Avatars
  • Web
  • Storage
IsItBathTime
12 Jul, 2023, 20:57

Hi, say I want to fetch this and display it on my html page. How would I do that? I usually use a img tag but not sure how it's done using the SDK. Any example would he appreciated πŸ™‚

TL;DR
The user is asking how to display an image on their website using the avatar/storage SDK on the web. They receive some advice and clarification on how to use the SDK. The solution is to use the href provided by the SDK as the URL for the image tag on the HTML page.
Drake
12 Jul, 2023, 21:26

what did you see when you logged the response?

IsItBathTime
12 Jul, 2023, 21:29

Url array which includes a href address. Do i just take that and throw it into a img tag?

Drake
12 Jul, 2023, 21:30

array? it should just be a url string 🧐 which you should be able to put into an img tag

IsItBathTime
12 Jul, 2023, 21:30
Drake
12 Jul, 2023, 21:31

ahhh this is a javascript URL object

IsItBathTime
12 Jul, 2023, 21:31

Its giving all of this, I'm not sure if I'm using the function it right just take the href

IsItBathTime
12 Jul, 2023, 21:31

Or as I supposed to use the whole thing to view the optimised image

IsItBathTime
12 Jul, 2023, 21:31

I see thanks I'll keep this terminology in mind

Drake
12 Jul, 2023, 21:32

so you can do response.toString() to get the URL string. see https://developer.mozilla.org/en-US/docs/Web/API/URL/toString

IsItBathTime
12 Jul, 2023, 21:35

Okay I know what it's doing now, I cna use the href it provides (not the same ws the one i supplied) as it can optionally add the width and height and it will scale it down to optimise for transfer 😁

IsItBathTime
12 Jul, 2023, 21:35

I'll try this too thanks

Drake
12 Jul, 2023, 21:36

ya, either works

IsItBathTime
12 Jul, 2023, 21:37

Thanks, thought it was making things more complicated for no reason but I understand what it's doing now πŸ˜… it's very useful! Cheers

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more