Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

72
Vistas
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.

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos