Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Using Image Field-How can the image selected center itself into the box?

Avatar

Level 1

I have a form using an image field so the client can click the box and drop  a picture into it.  When this is done, it does shrink the image to fit the box which is great but it seems to justify the image to the top left of the box.  Is there a way to have it center in the middle, horizontally and vertically?

5 Replies

Avatar

Level 10

Hi,

I don't think that you can change this behaviour. It can be annoying, but I think we are stuck with it.

Changing the scaling to fit rectangle will use the full extent of the image field, but may distort the original aspect ratio.

Niall

Avatar

Level 1

Actually I just figured it out!  Use the script "this.para.hAlign = "center";" and it seems to do it.  Also works on text fields :-)

Avatar

Level 10

Well done! Good catch! 

this.para.hAlign = "center";

this.para.vAlign = "middle";

Works in the docReady event and retains the settings as the user changes images.

Niall

Avatar

Level 1

where do you put that code in?  I'm lost...

Avatar

Level 1

Like a lot of things with LiveCycle, Ive learned in the few days since I have been using it that nothing is easy to find even if you are familiar with Adobe products.

But scripts are entered into Window/Scripts Editor.  It shows as a tool bar at the top of the page.  Click on your text box that you want the script to be used on, then select Initalize in the editor, and enter the code in the window next to it