Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To let EZM take a custom image location and image extension #5

Open
cosmicbhejafry opened this issue Jul 31, 2023 · 0 comments
Open

Comments

@cosmicbhejafry
Copy link

cosmicbhejafry commented Jul 31, 2023

I use the EZM javascript snippet to display some of my zines on my webpage, and I use the following snippet of code to give more flexibility with embedding zines as I want; it could potentially be helpful so posting it as an issue!

Basically the idea is to have an element with the id "zine" and set the values "base-url" and "ext-val" for this element. "base-url" is the equivalent of /pages/ i.e. the place where the images are stored (could be ./pages/, could be a URL, or a path to another directory like ./another/directory/structure/) and "ext-val" is the image extension being used

var name_val = './pages/';
if(document.getElementById("zine").hasAttribute("name_val")){
  name_val = document.getElementById("zine").getAttribute("base-url");
} 

console.log(name_val);

var ext_val = '.png'; //default images are pngs
if(document.getElementById("zine").hasAttribute("ext-val")){
  ext_val = document.getElementById("zine").getAttribute("ext-val");
} 

function getTextures(num) {
    return [name_val+'FRONT'+ext_val, name_val+'INNERFRONT'+ext_val].concat(
        new Array(num).fill().map((_, idx) => name_val+ + (idx + 1) + ext_val),
        [name_val+'BACK'+ext_val]
    );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant