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

258
Views
HTML how to get canvas resource file?

The picture on the HTML page is represented as a canvas, but I have problems getting the source image name of this canvas, using javascript.

enter image description here

Page: https://www.futbin.com/22/squad-builder

I found this image in the page resources: enter image description here

But how to get it programmically? I mean, if i have:

var canvas = document.getElementById('field-area')

How to get the file name? Result should be "field_1920x1080.png?v=8"

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use HTMLCanvasElement.toDataURL to get the image drawn on the canvas base64 encoded

var canvas = document.getElementById('field-area');
var b64url = canvas.toDataURL('image/png');

This will return the url for the image itself, i don't think you can get the Asset name directly from a canvas element without inspecting the code on the website

about 4 years ago · Juan Pablo Isaza Report

0

EJBEAN is right, the canvas element doesn't know what resources were used to draw.

Why don't you use dataset to keep an eye on what you used?

var canvas = document.getElementById('field-area');
// ... draw resource here
canvas.dataset.resource = "field_1920x1080.png";

It's an easy way to keep data stored for any element on your page.

about 4 years ago · Juan Pablo Isaza Report
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!