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

183
Views
Using relative path for fabricjs custom controls

Hi community sorry if my request is not perfect... but i'm absolutely new in the area of programming and this forum.

I costumized some fabric controls as in this demo http://fabricjs.com/custom-control-render and it works perfect with an absoulute path see below.

var deleteImg = document.createElement('img');
deleteImg.src = 'myHost/stage/controls/deleteIcon.svg';

Now I want add the path for the icons in the directory structure where the script is saved. I.e.

// scriptfolder = ../_public/js/main.js
// iconfolder = ../_public/img/*.svg
deleteImg.src = '../img/deleteIcon.svg';

I absolutely tried every possible constalation with relative paths. What i am doing wrong? I also tried doing this.

// iconfolder = ../_public/js/*.svg
var deleteImg = document.createElement('img');
deleteImg.src = 'deleteIcon.svg';

and this,

var locationpath = window.location.origin;
rotateImg.src = locationpath + '/stage/controls/deleteIcon.svg';

Which works fine as well like the absolute path. But actually I staging the project and when I switch to the production environment, the stage folder disappears and the url no longer works.

It can't be that hard to just specify the path relative to the script, can it? Thanks for your help.

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!