Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / Img.js
1 /**
2  * @class Ext.Img
3  * @extends Ext.Component
4  *
5  * Simple helper class for easily creating image components. This simply renders an image tag to the DOM
6  * with the configured src.
7  *
8  * {@img Ext.Img/Ext.Img.png Ext.Img component}
9  *
10  * ## Example usage: 
11  *
12  *     var changingImage = Ext.create('Ext.Img', {
13  *         src: 'http://www.sencha.com/img/20110215-feat-html5.png',
14  *         renderTo: Ext.getBody()
15  *     });
16  *      
17  *     // change the src of the image programmatically
18  *     changingImage.setSrc('http://www.sencha.com/img/20110215-feat-perf.png');
19 */
20 Ext.define('Ext.Img', {
21     extend: 'Ext.Component',
22     alias: ['widget.image', 'widget.imagecomponent'],
23     /** @cfg {String} src The image src */
24     src: '',
25
26     getElConfig: function() {
27         return {
28             tag: 'img',
29             src: this.src
30         };
31     },
32     
33     /**
34      * Updates the {@link #src} of the image
35      */
36     setSrc: function(src) {
37         var me = this,
38             img = me.el;
39         me.src = src;
40         if (img) {
41             img.dom.src = src;
42         }
43     }
44 });