Created
April 29, 2025 20:36
-
-
Save TitusRobyK/fae31ef1939efccee9d81b1c1baecb86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.sling.api.resource.Resource | |
| import org.apache.sling.api.resource.ResourceResolver | |
| import org.apache.sling.api.resource.ValueMap | |
| def rootPath = "/content/wknd/us/en" | |
| Resource root = resourceResolver.getResource(rootPath) | |
| if (root == null) { | |
| println "ERROR: Path not found: ${rootPath}" | |
| return | |
| } | |
| def images = [] as Set<String> | |
| def traverse | |
| traverse = { Resource res -> | |
| ValueMap props = res.adaptTo(ValueMap) | |
| if (props) { | |
| def fileRef = props.get("fileReference", String) | |
| if (fileRef) { | |
| images << fileRef | |
| } | |
| def src = props.get("src", String) | |
| if (src) { | |
| images << src | |
| } | |
| ["imagePath","poster","thumbnail"].each { key -> | |
| def v = props.get(key, String) | |
| if (v) { images << v } | |
| } | |
| } | |
| res.listChildren().each { traverse(it) } | |
| } | |
| traverse(root) | |
| println "\nFound ${images.size()} unique image references under ${rootPath}:\n" | |
| images.sort().each { println it } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment