Skip to content

Commit

Permalink
solves adobe#2625: Add feature to disable the featured page image inh…
Browse files Browse the repository at this point in the history
…eritance
  • Loading branch information
michielspiritus7 committed Nov 24, 2023
1 parent 14e70e3 commit 144e3d8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Optional;
import java.util.Set;

import com.adobe.cq.wcm.core.components.models.Image;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
Expand Down Expand Up @@ -344,9 +345,10 @@ public static Resource getWrappedImageResourceWithInheritance(Resource resource,
String fileReference = properties.get(DownloadResource.PN_REFERENCE, String.class);
Resource fileResource = resource.getChild(DownloadResource.NN_FILE);
boolean imageFromPageImage = properties.get(PN_IMAGE_FROM_PAGE_IMAGE, StringUtils.isEmpty(fileReference) && fileResource == null);
boolean disblePageImageInheritance = currentStyle != null ? currentStyle.get(Image.PN_PAGE_IMAGE_INHERITANCE_DISABLED, false) : false;
boolean altValueFromPageImage = properties.get(PN_ALT_VALUE_FROM_PAGE_IMAGE, imageFromPageImage);

if (imageFromPageImage) {
if (!disblePageImageInheritance && imageFromPageImage) {
Resource inheritedResource = null;
String linkURL = properties.get(ImageResource.PN_LINK_URL, String.class);
boolean actionsEnabled = (currentStyle != null) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public interface Image extends Component {
*/
String PN_IMAGE_FROM_PAGE_IMAGE = "imageFromPageImage";

/**
* Name of the content policy property that will indicate if the image inheritance the featured image of the page is disabled.
*
* @since com.adobe.cq.wcm.core.components.models 12.29.0
*/
String PN_PAGE_IMAGE_INHERITANCE_DISABLED = "disablePageImageInheritance";

/**
* Name of the resource property that will indicate if the value of the {@code alt} attribute should be inherited
* from the featured image of the page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* version, is bound to this proxy component resource type.
* </p>
*/
@Version("12.28.1")
@Version("12.29.0")
package com.adobe.cq.wcm.core.components.models;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
checked="{Boolean}false"
uncheckedValue="false"
value="{Boolean}true"/>
<disablePageImageInheritance
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
fieldDescription="When checked, it will not inherit the featured image from the page."
name="./disablePageImageInheritance"
text="Disable Page Image Inheritance"
checked="{Boolean}false"
uncheckedValue="false"
value="{Boolean}true"/>
<decorative
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
Expand Down

0 comments on commit 144e3d8

Please sign in to comment.