Giter Site home page Giter Site logo

Comments (3)

luciopaiva avatar luciopaiva commented on May 29, 2024

That's a very nice question.

There is currently no way of directly including resource types other than JS and CSS. However, you could try one of these tricks:

  • embed the resource into your JS file: here's an example. You'd just need to get a base64 representation of the image;
  • embed the resource into your CSS file: this article shows an example. The same conversion to base 64 applies;
  • use the local web server to retrieve the image: since Witchcraft relies on a local web server running, that same web server can be used by your script to load an image, so you don't have to embed it like the two previous options. Move the resource to the same folder where your Witchcraft scripts live, open your Witchcraft pop-up window, copy the web server address from there, then append to it the name of your resource file (e.g. http://127.0.0.1:5743/foo.png). You can then reference this address in your JS or CSS to load your image directly.

I'd go with the last option, which seems to be the easiest. Please let me know if you were able to do it.

from witchcraft.

luciopaiva avatar luciopaiva commented on May 29, 2024

Added this question to the FAQ. I am closing the issue, but please feel free to continue the discussion if you'd like to.

from witchcraft.

luciopaiva avatar luciopaiva commented on May 29, 2024

Notice that you may have run into CORS issues when trying to fetch resources from http://127.0.0.1:5743. Configure your HTTP scripts server to set the proper CORS headers.

If using the recommended Web Server Chrome app, open its settings, click "Show Advanced Options" and then check the "Set CORS headers" option:

image

from witchcraft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.