Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 7421)
+++ /CKEditor/trunk/CHANGES.html	(revision 7422)
@@ -40,5 +40,5 @@
 			New features:</p>
 	<ul>
-		<li></li>
+		<li><a href="http://dev.ckeditor.com/ticket/7430">#7430</a> : Justify commands now performs alignment on the element when image is selected.</li>
 	</ul>
 	<p>
Index: /CKEditor/trunk/_source/core/command.js
===================================================================
--- /CKEditor/trunk/_source/core/command.js	(revision 7421)
+++ /CKEditor/trunk/_source/core/command.js	(revision 7422)
@@ -50,5 +50,21 @@
 			editor.focus();
 
+		if ( this.fire( 'exec' ) === true )
+			return true;
+
 		return ( commandDefinition.exec.call( this, editor, data ) !== false );
+	};
+
+	/**
+	 * Explicitly update the status of the command, by firing the {@link CKEDITOR.command#event:refresh} event,
+	 * as well as invoke the {@link CKEDITOR.commandDefinition.prototype.refresh} method if defined, this method
+	 * is to allow different parts of the editor code to contribute in command status resolution.
+	 */
+	this.refresh = function()
+	{
+		if ( this.fire( 'refresh' ) === true )
+			return true;
+
+		return ( commandDefinition.refresh && commandDefinition.refresh.apply( this, arguments ) !== false );
 	};
 
Index: /CKEditor/trunk/_source/plugins/image/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/image/plugin.js	(revision 7421)
+++ /CKEditor/trunk/_source/plugins/image/plugin.js	(revision 7422)
@@ -7,4 +7,7 @@
  * @file Image plugin
  */
+
+(function()
+{
 
 CKEDITOR.plugins.add( 'image',
@@ -54,12 +57,92 @@
 			editor.contextMenu.addListener( function( element, selection )
 				{
-					if ( !element || !element.is( 'img' ) || element.data( 'cke-realelement' ) || element.isReadOnly() )
-						return null;
-
-					return { image : CKEDITOR.TRISTATE_OFF };
+					if ( getSelectedImage( editor, element ) )
+						return { image : CKEDITOR.TRISTATE_OFF };
 				});
 		}
+	},
+	afterInit : function( editor )
+	{
+		// Customize the behavior of the alignment commands. (#7430)
+		setupAlignCommand( 'left' );
+		setupAlignCommand( 'right' );
+		setupAlignCommand( 'center' );
+		setupAlignCommand( 'block' );
+
+		function setupAlignCommand( value )
+		{
+			var command = editor.getCommand( 'justify' + value );
+			if ( command )
+			{
+				if ( value == 'left' || value == 'right' )
+				{
+					command.on( 'exec', function( evt )
+						{
+							var img = getSelectedImage( editor ), align;
+							if ( img )
+							{
+								align = getImageAlignment( img );
+								if ( align == value )
+								{
+									img.removeStyle( 'float' );
+
+									// Remove "align" attribute when necessary.
+									if ( value == getImageAlignment( img ) )
+										img.removeAttribute( 'align' );
+								}
+								else
+									img.setStyle( 'float', value )
+
+								evt.cancel();
+							}
+						});
+				}
+
+				command.on( 'refresh', function( evt )
+					{
+						var img = getSelectedImage( editor ), align;
+						if ( img )
+						{
+							align = getImageAlignment( img );
+
+							this.setState(
+								( align == value ) ? CKEDITOR.TRISTATE_ON :
+								( value == 'right' || value == 'left' ) ? CKEDITOR.TRISTATE_OFF :
+								CKEDITOR.TRISTATE_DISABLED );
+
+							evt.cancel();
+						}
+					});
+			}
+		}
 	}
-} );
+});
+
+function getSelectedImage( editor, element )
+{
+	if ( !element )
+	{
+		var sel = editor.getSelection();
+		element = ( sel.getType() == CKEDITOR.SELECTION_ELEMENT ) && sel.getSelectedElement();
+	}
+
+	if ( element && element.is( 'img' ) && !element.data( 'cke-realelement' ) && !element.isReadOnly() )
+		return element;
+}
+
+function getImageAlignment( element )
+{
+	var align = element.getStyle( 'float' );
+
+	if ( align == 'inherit' || align == 'none' )
+		align = 0;
+
+	if ( !align )
+		align = element.getAttribute( 'align' );
+
+	return align;
+}
+
+})();
 
 /**
Index: /CKEditor/trunk/_source/plugins/justify/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/justify/plugin.js	(revision 7421)
+++ /CKEditor/trunk/_source/plugins/justify/plugin.js	(revision 7422)
@@ -10,16 +10,4 @@
 (function()
 {
-	function getState( editor, path )
-	{
-		var firstBlock = path.block || path.blockLimit;
-
-		if ( !firstBlock || firstBlock.getName() == 'body' )
-			return CKEDITOR.TRISTATE_OFF;
-
-		return ( getAlignment( firstBlock, editor.config.useComputedState ) == this.value ) ?
-			CKEDITOR.TRISTATE_ON :
-			CKEDITOR.TRISTATE_OFF;
-	}
-
 	function getAlignment( element, useComputedState )
 	{
@@ -41,5 +29,6 @@
 		}
 
-		align && ( align = align.replace( /-moz-|-webkit-|start|auto/i, '' ) );
+		// Sometimes computed values doesn't tell.
+		align && ( align = align.replace( /(?:-(?:moz|webkit)-)?(?:start|auto)/i, '' ) );
 
 		!align && useComputedState && ( align = element.getComputedStyle( 'direction' ) == 'rtl' ? 'right' : 'left' );
@@ -53,11 +42,10 @@
 			return;
 
-		var command = evt.editor.getCommand( this.name );
-		command.state = getState.call( this, evt.editor, evt.data.path );
-		command.fire( 'state' );
+		evt.editor.getCommand( this.name ).refresh( evt.data.path );
 	}
 
 	function justifyCommand( editor, name, value )
 	{
+		this.editor = editor;
 		this.name = name;
 		this.value = value;
@@ -193,4 +181,14 @@
 			editor.forceNextSelectionCheck();
 			selection.selectBookmarks( bookmarks );
+		},
+
+		refresh : function( path )
+		{
+			var firstBlock = path.block || path.blockLimit;
+
+			this.setState( firstBlock.getName() != 'body' &&
+				getAlignment( firstBlock, this.editor.config.useComputedState ) == this.value ?
+				CKEDITOR.TRISTATE_ON :
+				CKEDITOR.TRISTATE_OFF );
 		}
 	};
