Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Attachments #1

Open
adamopenweb opened this issue Feb 4, 2014 · 1 comment
Open

Attachments #1

adamopenweb opened this issue Feb 4, 2014 · 1 comment

Comments

@adamopenweb
Copy link
Collaborator

Could be valuable to have attachments from the bug included on the site. Helps to visualize the problem.

@hallvors
Copy link
Contributor

For a simple hack, this would do: At the end of this method

  parse: function(response, options) {
    var response = response.bugs[this.bugID];
    this.sanitize(response.comments);
    this.set("firstComment", response.comments[0].raw_text.trim());
    this.getDescription(response);
    this.getSuggestedFix(response);
    this.set("summary", this.sanitize(simplebug.summary));
    }
  },

add this code:

    for(var i=0, comment; comment = response.comments[i]; i++){
        if(comment.attachment_id){
            var img = document.createElement('img');
            img.onload = function(){ img.style.width='80%'; img.alt = 'Screenshot or comparison screenshot of website'; document.getElementById('description').appendChild(img); }
            img.onerror = function(){img=null;}
            img.src = 'https://bug'+ this.bugID +'.bugzilla.mozilla.org/attachment.cgi?id=' + comment.attachment_id;
        }

The attachments API described here http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html#Bug_Information seems to be a bit heavy, returning full data of the attachment, BASE64 encoded. We don't really need that - all we need is a URL, and a way to tell it is an image.

The approach above is a bit hackish (create an image and assume that if onload fires it was indeed image data).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants