Skip to content

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

@cosmicbhejafry

Description

@cosmicbhejafry

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]
    );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions