Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
How to automatically download an image from YouTube frontend with no file extension in src field? (JavaScript)

For my research, I use JavaScript to download data of the top YouTube comments that are shown to a user, that is why I am using data from the YouTube frontend and not the YouTube API. Apart from comment text, number of likes, etc. I would also like to store the profile pictures of the people leaving comments. The img tag looks like this:

<img id="img" class="style-scope yt-img-shadow" alt="name" height="40" width="40"
src="https://yt3.ggpht.com/ytc/AKedOLSXk4DiR7nlvyuGiByOeaJmg4pH8Yt2FAqoVy73YQ=s48-c-k-c0x00ffffff-no-rj">

The problem that I am experiencing is that the src attribute does not have an extension at the end, so when I am trying to download a .jpg image with the code listed below, the image is just opened in a new tab and the link from the src attribute is saved as a .jpg file, which is not interpreted correctly. I also tried adding an extension like .png or .jpg at the end of the link, but it didn't work.

function downloadImage(imageSrc) {
  const link = document.createElement('a')
  link.href = imageSrc
  link.download = 'image.jpg'
  document.body.appendChild(link)
  link.click()
  document.body.removeChild(link)
}

The solutions that I found so far:

  1. Save Image file from Image URL javascript html

  2. How to view the full background image of a YouTube channel?

Unfortunately, they don't consider the case with no extension in the src attribute when the images should be saved automatically with JavaScript.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!