Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda