This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git


The following commit(s) were added to refs/heads/master by this push:
     new 100a0ba  Resolving SLING-8850 Adding transformation support in the 
image reference component
100a0ba is described below

commit 100a0ba0435db0cf92509c6bc12adeb10fe801b9
Author: Dan Klco <[email protected]>
AuthorDate: Sun Nov 17 15:47:16 2019 -0500

    Resolving SLING-8850 Adding transformation support in the image
    reference component
---
 .../reference/components/general/image/edit.json   | 27 ++++++++++++++++++++++
 .../reference/components/general/image/image.jsp   |  5 +++-
 .../image/{image.jsp => transformations.jsp}       | 12 ++++++----
 3 files changed, 39 insertions(+), 5 deletions(-)

diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
index f123dd8..ef07361 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
@@ -15,6 +15,33 @@
             "titleProperty": "jcr:content/jcr:title",
             "required": true
         },
+        "transformation": {
+            "jcr:primaryType": "nt:unstructured",
+            "sling:resourceType": "sling-cms/components/editor/fields/select",
+            "label": "Transformation",
+            "name": "transformation",
+            "required": false,
+            "optionsScript": 
"/apps/reference/components/general/image/transformations.jsp"
+        },
+        "transformationFormat": {
+            "jcr:primaryType": "nt:unstructured",
+            "sling:resourceType": "sling-cms/components/editor/fields/select",
+            "label": "Transformation Format",
+            "name": "transformationFormat",
+            "required": false,
+            "options": {
+                "png": {
+                    "jcr:primaryType": "nt:unstructured",
+                    "label": "PNG",
+                    "value": "png"
+                },
+                "jpg": {
+                    "jcr:primaryType": "nt:unstructured",
+                    "label": "Jpeg",
+                    "value": "jpeg"
+                }
+            }
+        },
         "alt": {
             "jcr:primaryType": "nt:unstructured",
             "sling:resourceType": "sling-cms/components/editor/fields/text",
diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
index 49658b3..f5d9d4c 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
@@ -18,5 +18,8 @@
  */ --%>
 <%@include file="/libs/sling-cms/global.jsp"%>
 <c:if test="${not empty properties.src}">
-    <img src="${properties.src}" alt="${properties.alt}" 
class="${properties.imageClass}" />
+    <c:if test="${not empty properties.transformation}">
+        <c:set var="transform" 
value=".transform/${properties.transformation}.${properties.transformationFormat}"
 />
+    </c:if>
+    <img src="${properties.src}${transform}" alt="${properties.alt}" 
class="${properties.imageClass}" />
 </c:if>
\ No newline at end of file
diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/transformations.jsp
similarity index 58%
copy from 
reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
copy to 
reference/src/main/resources/jcr_root/apps/reference/components/general/image/transformations.jsp
index 49658b3..817cd2a 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/transformations.jsp
@@ -16,7 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */ --%>
-<%@include file="/libs/sling-cms/global.jsp"%>
-<c:if test="${not empty properties.src}">
-    <img src="${properties.src}" alt="${properties.alt}" 
class="${properties.imageClass}" />
-</c:if>
\ No newline at end of file
+ <%@include file="/libs/sling-cms/global.jsp"%>
+<sling:adaptTo adaptable="${slingRequest.requestPathInfo.suffixResource}" 
adaptTo="org.apache.sling.cms.transformer.TransformationManager" 
var="transformationManager" />
+<option value="">None</option>
+<c:forEach var="transformation" 
items="${transformationManager.transformations}">
+    <option 
${slingRequest.requestPathInfo.suffixResource.valueMap.transformation == 
transformation.name ? 'selected' : ''} 
value="${sling:encode(transformation.name,'HTML_ATTR')}">
+        ${sling:encode(transformation.name,'HTML')}
+    </option>
+</c:forEach>
\ No newline at end of file

Reply via email to