Show More
@@ -614,18 +614,20 b' var IPython = (function (IPython) {' | |||||
614 | }, 250); |
|
614 | }, 250); | |
615 | }; |
|
615 | }; | |
616 |
|
616 | |||
|
617 | var set_width_height = function (img, md, mime) { | |||
|
618 | // set width and height of an img element from metadata | |||
|
619 | var height = _get_metadata_key(md, 'height', mime); | |||
|
620 | if (height !== undefined) img.setAttribute('height', height); | |||
|
621 | var width = _get_metadata_key(md, 'width', mime); | |||
|
622 | if (width !== undefined) img.setAttribute('width', width); | |||
|
623 | }; | |||
617 |
|
624 | |||
618 | OutputArea.prototype.append_png = function (png, md, element) { |
|
625 | OutputArea.prototype.append_png = function (png, md, element) { | |
619 | var type = 'image/png'; |
|
626 | var type = 'image/png'; | |
620 | var toinsert = this.create_output_subarea(md, "output_png", type); |
|
627 | var toinsert = this.create_output_subarea(md, "output_png", type); | |
621 | var img = $("<img/>"); |
|
628 | var img = $("<img/>"); | |
622 | img[0].setAttribute('src','data:image/png;base64,'+png); |
|
629 | img[0].setAttribute('src','data:image/png;base64,'+png); | |
623 | if (md['height']) { |
|
630 | set_width_height(img[0], md, 'image/png'); | |
624 | img[0].setAttribute('height', md['height']); |
|
|||
625 | } |
|
|||
626 | if (md['width']) { |
|
|||
627 | img[0].setAttribute('width', md['width']); |
|
|||
628 | } |
|
|||
629 | this._dblclick_to_reset_size(img); |
|
631 | this._dblclick_to_reset_size(img); | |
630 | toinsert.append(img); |
|
632 | toinsert.append(img); | |
631 | element.append(toinsert); |
|
633 | element.append(toinsert); | |
@@ -636,12 +638,7 b' var IPython = (function (IPython) {' | |||||
636 | var type = 'image/jpeg'; |
|
638 | var type = 'image/jpeg'; | |
637 | var toinsert = this.create_output_subarea(md, "output_jpeg", type); |
|
639 | var toinsert = this.create_output_subarea(md, "output_jpeg", type); | |
638 | var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg); |
|
640 | var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg); | |
639 | if (md['height']) { |
|
641 | set_width_height(img[0], md, 'image/jpeg'); | |
640 | img.attr('height', md['height']); |
|
|||
641 | } |
|
|||
642 | if (md['width']) { |
|
|||
643 | img.attr('width', md['width']); |
|
|||
644 | } |
|
|||
645 | this._dblclick_to_reset_size(img); |
|
642 | this._dblclick_to_reset_size(img); | |
646 | toinsert.append(img); |
|
643 | toinsert.append(img); | |
647 | element.append(toinsert); |
|
644 | element.append(toinsert); |
General Comments 0
You need to be logged in to leave comments.
Login now