Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solves #2625: Add feature to disable the featured page image inheritance #2626

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo in variable name, I believe it should be disablePageImageInheritance

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
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
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;
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