Thursday, 31 October 2019

Moving Dam Assets or Page

Some times we need to change the structure of our Dam, that is simple thing but to change the references of those assets on every page where ever we used the same, is so difficult.

In this blog, I am going to tell you that how to move assets/page from one folder to other folder and reference also will be changed automatically.

To achieve this, we need ACS Commons package 3.19.0

Dam asset movement can be done using MCP Tools - Renovator.

Follow below step to perform it:

1. Go to Tools → ACS AEM Commons → Managed Controlled Processes


2. When you click on the same Managed Controlled Processes dashboard will open. Click on "Start Process" button.


3. On clicking "Start Process" button, process list will open, select "Renovator" process from the list. 


4. On selecting Renovator process , following screen will display :

  • Multiple moves: If desired, multiple moves can be specified in a spreadsheet instead of moving one folder at a time. This is explained below.
  • Source: The page, folder, or asset being moved and/or renamed
  • Destination: The full path of the destination for the folder or page. This must include the desired name. If you want to retain the current name then make sure destination ends with that same name. Otherwise, change as desired.
  • Max references: The maximum number of references to evaluate per page. -1 defaults to all (recommended)
  • Publish mode: You can use MCP to publish affected live content (self managed), defer to the standard product queue, or disable publishing (none).
  • Create versions: If checked a page content affected by republishing will create a new version.
  • Update status: If checked, node metadata for last published will be updated.
  • Extensive ACL Checks: If checked, every child node is evaluated during step 1 (this can get very expensive for large trees!). If unchecked, only base nodes are evaluated, such as the base node of each asset or page but not the children such as metadata or component nodes. Recommended: Leave it unchecked.
  • Dry Run: If checked, no moves or publish operations happen but the report is generated, and ACL checks are performed. This lets you see what will be affected by this operation.
  • Detailed Report: If checked, the final report will list all content moved by the process. If unchecked, only summary counts are provided.

5. Now I will show you how to fill this Renovator process and what will be change and how reference will be change automatically.

First, I am going to show you my page dialog where I am using image path to which I am going to change from Renovator.


As you can see highlighted part in dialog where we are using this path "/content/dam/dcu/global/home/images/..".
Now I will move all the images from /dcu/global/home/images/.. to /content/dam/dcu/gaurav/images/..

So, lets fill the process dashboard:


Click on start button. it will take few millisecond to move. Now, If you will see in your dam structure, all the images from /content/dam/dcu/global/home/images has been moved to dam/dcu/gaurav/images.

Now, if you will check on your page or dialog where you used these images the References of all the images should be change.


Multiple Moves:

In the start process dialog, the source and destination fields allow moving one page or one folder or one image(as well as all the children). If you want to list a lot more sources and destinations, a simple spreadsheet can be prepared with that list as such:

1. Create a new spreadsheet (the file name does not matter but it needs to be of type XLSX)
2. In the first row, set the first two columns to “Source” and “Destination” respectively. Order doesn’t matter, and also if there are other columns they are ignored.
3. For each move, add a row that specifies the source and destination of the move you want. It is possible to list multiple sources that all have the same destination (merge folders) but you should not try to move the same source folder to multiple destinations. That’s just silly.
4. Save the file as an XSLX spreadsheet and close Excel (this step is important)
5. When starting the Renovator process, leave source and destination blank and provide the spredsheet for the “Multiple Moves” field.
6. Set all other fields as needed, it is recommended to use a dry run the first time in order to validate the file as well as report what will be affected.

Excel format will be like below image:



Be Happy 😊

Friday, 20 September 2019

AEM 6.4 Touch UI Rich Text Editor Remove Bold and Add Strong

AEM RTE Bold plugin wraps text with "b" tag by default, but now "b" tag is not recommended so far and for accessibility also we need "Strong" tag.

<b> is a style - we know what "bold" is supposed to look like.

<strong> however is an indication of how something should be understood. "Strong" could (and often does) mean "bold" in a browser, but it could also mean a lower tone for a speaking program like Jaws (for blind people) or be represented by an underline (since you can't bold a bold) on a Palm Pilot.

So in this blog I am going to tell you how can we change "b" tag in to "Strong" tag.

1. Add htmlRules node of type nt:unstructured in parallel of rtePlugins node.

       Note: Name of htmlRules node can't be change.



2. Add docType/typeConfig node of type nt:unstructured under htmlRules node.
3. Set the property useSemanticMarkup={Boolean}true on typeConfig node.



For testing your configuration Drop your component on a page and open dialog and configure your RTE and save. After save the dialog, go to the inspect element and see your bold text. That should be between <Strong> tag.



Be Happy 😊

Saturday, 15 June 2019

Named Transform Image Servlet (Image Renditions on the Fly)

ACS Commons Package version 3.19.0
Available version for this servlet is 1.5.0.

Purpose: 


Many web site designs demands consistency of images based on their use within components. For example, a panoramic spotlight may demand the image be 960 x 400, and bio picture must be 100 x 100 and greyscale.

Some times we have some images on which we can not use image renditions generated by out of the box because of their cropped size. In that case we have to use our different types of dimensions for different types of component.

The ACS AEM Commons Named Transform Image Servlet allows specific image transforms to be defined centrally via OSGI configurations. These image transforms can be easily invoked via parameterized HTTP GET requests to image resources in AEM.

So let see about ACS AEM Commons provided Image Transformers and how to use these transformers and what will the effect of these on images.

Supported “image-y” resources

Almost any “image-like” resource can be requested using the named transform URI parameterization, and the underlying image will be derived and rendered using the transformation parameters.

Pages (cq:Page):
     HTTP GET /content/acme/article.transform/feature/image.png

Image component resources:
    HTTP GET /content/acme/article/_jcr_content/image.transform/feature/image.png

DAM Assets (dam:Asset):
    HTTP GET /content/dam/images/dog.jpg.transform/feature/image.jpg

DAM Asset Renditions"
    HTTP GET                 /content/dam/images/dog.jpg/jcr:content/renditions/thumbnail.jpg.transform/feature/image.jpg

   “Raw” Binary Images (nt:file or nt:resource):
     HTTP GET /etc/designs/acme/images/cat.png.transform/feature/image.jpg


1. Resize:

Resizes the image to the specified width and/or height.
Name

  • Resize
Params

  • width=[width in px]
  • height=[height in px]Example
Example
  • resize:width=200
  • resize:height=300
  • resize:width=400&height=400

How to use:

  • Define any number of sling:OsgiConfig’s, each representing a different named transform
/apps/mysite/config/com.adobe.acs.commons.images.impl.NamedImageTransformerImpl-myTransformName.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="sling:OsgiConfig"
    name="my-transform"
    transforms="[resize:width=400&height=400]"/>





  • Get the URI to a supported resource (see above) to transform
  • add the .transform extension (append this even if the resource is named with an extension; like a DAM asset)
  • Add an initial suffix segment that matches your transform name (Ex. /my-transform)
  • Add a final suffix segment of /image.<image-format-extension> OR /img.<image-format-extension>
Resulting in

<img src="/content/mysite/article/_jcr_content/image.transform/my-transform/image.png"/>

or

<img src="/content/dam/images/dog.jpg.transform/my-transform/img.png"/>

The below DAM Asset image has been resizes as defined by the custom defined my-transform transform rule set.

bc http://localhost:4502/content/dam/we-retail/en/activities/hiking/hiking_5.jpg.transform/my-transform/image.jpg


Resized Image


Original Image

2. Bounded Resize (v1.8.0+)

Resizes the image but will not resize past maximum dimension constraints. Accepts two Integer params: height and width. Either width or height will scale to the parameterized limit. The other dimension scale automatically to maintain the original aspect ratio. If the original image is smaller than the configured dimensions the image won’t be resized. Upscale param can be set to true to allow upscaling smaller images.

Name
  • bounded-resize
Params
  • width=[width in px]
  • height=[height in px]
  • upscale=true/false
Example
  • bounded-resize:width=200
  • bounded-resize:height=300
  • bounded-resize:width=400&height=400&upscale=true

How to use:

The below DAM Asset image has been resizes as defined by the custom defined my-transform-bounded transform rule set.

bc. http://localhost:4502/content/dam/we-retail/en/activities/hiking/hiking_5.jpg.transform/my-transform-bounded/image.jpg


Bounded-resize

3. Crop

Crops the image to the specified bounds.

Name
  • crop
Params
  • bounds=[x,y,width,height]
  • smart=[boolean] Defaults to true. Smart bounding will attempt to shift the specified crop-zone to fit within the image dimensions if the crop-zone falls outside the images dimensions.
Example
  • crop:bounds=0\,10\,300\,350
  • crop:bounds=0\,10\,300\,350&smart=false
  • crop:bounds=25%\,0\,50%\,100%
    • Relative cropping available since v2.8.0/3.4.0

How to use:


The below DAM Asset image has been cropped as defined by the custom defined my-transform-crop transform rule set.





4. Greyscale

Converts the image to greyscale.

Name
  • greyscale
Params
  • None
Example
  • greyscale

If we want to use all configs in single transform rule than we can use. config will be like this:



The below DAM Asset image has been resizes, cropped and greyscaled as defined by the custom defined my-transform-all transform rule set.



 Note: Order matters when defining your image transformation rules. For example, a resize then crop can yield significantly different results than a crop then resize.

Be Happy😊