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

@height and @width on graphic ignored #71

Open
lb42 opened this issue Dec 2, 2024 · 1 comment
Open

@height and @width on graphic ignored #71

lb42 opened this issue Dec 2, 2024 · 1 comment

Comments

@lb42
Copy link
Member

lb42 commented Dec 2, 2024

I added a behavio/u/r as suggested in the "anatomy of behaviors" document

 "graphic": function(elt) {
      let content = new Image();
      content.src = this.rw(elt.getAttribute("url")); // "this" is the CETEI object.
      if (elt.hasAttribute("width")) {
        content.setAttribute("width",elt.getAttribute("width"));
      }
      if (elt.hasAttribute("height")) {
        content.setAttribute("height",elt.getAttribute("height"));
      }
      return content;
    },

The TEI document contains e.g. things like this:

<graphic url="http://commons.wikimedia.org/wiki/Special:FilePath/Gilbert%20Abbott%20%C3%A0%20Beckett.jpg" height="10%" width="10%"/>

but they are always displayed without any sort of scaling (I've also tried specifying a width in px or mm )

@hcayless
Copy link
Member

hcayless commented Dec 2, 2024

Looks like the built in graphic handler was broken in the refactoring. I'll fix it. Meanwhile if you change you code to:

"graphic": function(elt) {
  let content = elt.ownerDocument.createElement("img");
  content.src = this.rw(elt.getAttribute("url"));
  if (elt.hasAttribute("width")) {
    content.setAttribute("width",elt.getAttribute("width"));
  }
  if (elt.hasAttribute("height")) {
    content.setAttribute("height",elt.getAttribute("height"));
  }
  return content;
}

I think it will be happy.

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

2 participants