Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…re-wcm-components into feature/video-v1
  • Loading branch information
georgecamilar committed Jun 14, 2021
2 parents 1cd14e9 + 8dc70ab commit 6bde62c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
import com.day.cq.wcm.api.designer.Style;
import com.fasterxml.jackson.annotation.JsonIgnore;

import static com.day.cq.commons.jcr.JcrConstants.JCR_CONTENT;
import static com.day.cq.commons.jcr.JcrConstants.JCR_MIMETYPE;

@Model(adaptables = SlingHttpServletRequest.class, adapters = {Image.class, ComponentExporter.class}, resourceType = ImageImpl.RESOURCE_TYPE)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class ImageImpl extends AbstractComponentImpl implements Image {
Expand Down Expand Up @@ -171,7 +174,14 @@ protected void initModel() {
}
} else {
if (fileResource != null) {
mimeType = PropertiesUtil.toString(fileResource.getResourceMetadata().get(ResourceMetadata.CONTENT_TYPE), MIME_TYPE_IMAGE_JPEG);
mimeType = PropertiesUtil.toString(fileResource.getResourceMetadata().get(ResourceMetadata.CONTENT_TYPE), null);
if (StringUtils.isEmpty(mimeType)) {
Resource fileResourceContent = fileResource.getChild(JCR_CONTENT);
if (fileResourceContent != null) {
ValueMap fileProperties = fileResourceContent.getValueMap();
mimeType = fileProperties.get(JCR_MIMETYPE, MIME_TYPE_IMAGE_JPEG);
}
}
String fileName = properties.get(ImageResource.PN_FILE_NAME, String.class);
imageName = StringUtils.isNotEmpty(fileName) ? getSeoFriendlyName(FilenameUtils.getBaseName(fileName)) : "";
hasContent = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ private void transformAndStreamFile(SlingHttpServletResponse response, ValueMap
if (flipVertically) {
layer.flipVertically();
}
if (layer.getBackground().getTransparency() != Transparency.OPAQUE &&
("jpg".equalsIgnoreCase(mimeTypeService.getExtension(imageType))
|| "jpeg".equalsIgnoreCase(mimeTypeService.getExtension(imageType)))) {
LOGGER.debug("Adding default (white) background to a transparent JPG: {}", imageFile.getPath());
layer.setBackground(Color.white);
}
resizeAndStreamLayer(response, layer, imageType, resizeWidth, quality);
} else {
LOGGER.debug("No need to perform any processing on file {}; rendering.", imageFile.getPath());
Expand Down
2 changes: 1 addition & 1 deletion content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"sync-pom-version-to-package": "^1.6.0"
},
"dependencies": {
"@adobe/adobe-client-data-layer": "2.0.1"
"@adobe/adobe-client-data-layer": "2.0.2"
}
}

0 comments on commit 6bde62c

Please sign in to comment.