How do I extract the thumbnail URL from a given URL
so let's say I have like a list. each of them has a url.
I want to go through each of them and extract their thumbnail image url to display it.
Is this possible?
13 Replies
I think you'll have to be a bit more specific, maybe share an example
what does the list look like, for example
Ok so the
thumbnailUrl
is the one that I want to "automate" cuz I don't want to manually extract the thumbnail of each item
the href
is the link so people can click and visit the codepen pageright, so what do you mean by extract then?
I want to get the url string
of the thumbnail, like... open graph image or something
snippetList[0].thumbnailUrl
?
are you trying to show them in a list or something?ok sooo I want it to automatically get the
thumbnailUrl
without me manually typing into it
it's like when you put a link in Discord and it shows the previewoh, you have the codepen link but not the thumb url and want to generate it from the href field?
yes
I have the link but I want to automate the thumbnail
well, looking at the format you've got for the ones you filled in manually, you can probably just do some string substitution on the href
something like
you don't seem to need the version query param, I assume it'll always just give you the latest one
oh
I see. I thought I have to do like a fetch or something to grab the thumbnail
you'd have to check the API for codepen, if they have one, but the URL of the thumbnail is similar enough that you can just rewrite it yourself
thank god their url is similar 😆 . If they use a weird image url Im gonna have to do some crazy stuff to get the thumbnail
thanks for the help
no problem