How to configure path to open details for video. #990
Replies: 2 comments
-
Hi! Sorry for the delayed response! So the way the Details pages are resolves is via the "Asset Type" computed property via the AssetTypeSelector. (You can change the selector used in Search page's Page Properties, or implement a custom selector and select that from the dropdown.) (Unfortunately, in hindsight) we used the OOTB UIHelper [2] in the AssetType Computed Property implementation to come up with the values it returns. So for video assets the return value is If you want to have the page name be Youd want to then make sure you select "Custom" in the Search Page's PageProperties as the Asset Details selector. Here's an example of what a custom AssetDetailsSelector that uses "video.html" for videos and fallsback to the AssetType for everything else -- and should be easy enough to customize for other mimetypes. (please pardon syntax typos as i wrote this in this comment block without linter, etc. :) ) I'd be interested to understand what scheme you'd like to use to determine details pages tho - since its come up several times that using the "AssetType" doesnt make sense for more than a few people. package ...impl;
import com.adobe.aem.commons.assetshare.configuration.AssetDetailsSelector;
import com.adobe.aem.commons.assetshare.configuration.Config;
import com.adobe.aem.commons.assetshare.content.AssetModel;
import com.adobe.aem.commons.assetshare.content.properties.impl.AssetTypeImpl;
import org.apache.commons.lang3.StringUtils;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
@Component(
property = {
"label:String=" + CustomSelectorImpl.LABEL,
"id:String=" + CustomSelectorImpl.ID
},
service = AssetDetailsSelector.class
)
@Designate(ocd = CustomSelectorImpl.Cfg.class)
public class CustomSelectorImpl implements AssetDetailsSelector {
public static final String LABEL = "Custom";
public static final String ID = "custom";
private Cfg cfg;
@Reference(target = (component.name=com.adobe.aem.commons.assetshare.configuration.impl.selectors.AssetTypeSelectorImpl)")
private AssetDetailsSelector assetTypeSelector;
@Override
public String getLabel() {
return cfg.label();
}
@Override
public String getId() {
return cfg.id();
}
@Override
public boolean accepts(final Config config, final AssetModel asset) {
return StringUtils.equalsIgnoreCase(config.getAssetDetailsSelector(), ID);
}
@Override
public String getUrl(final Config config, final AssetModel asset) {
if (StringUtils.isBlank(config.getAssetDetailsPath())) {
return null;
}
String mimeType = asset.getProperties().get("dc:format", "");
if (StringUtils.strartsWith(mimeType, "video/") {
return config.getAssetDetailsPath() + "/video.html";
// you can do similar for other asset types. You can even check the asset's extension if you dont want to look at its mimetype -- or some combination thereof
} else {
return assetTypeSelector.getUrl(config, asset);
}
}
@Activate
protected void activate(Cfg cfg) {
this.cfg = cfg;
}
@ObjectClassDefinition(name = "Asset Share Commons - Asset Details Selector - Custom")
public @interface Cfg {
@AttributeDefinition(
name = "Label",
description = "Human read-able label."
)
String label() default LABEL;
@AttributeDefinition(
name = "ID",
description = "Defines the id of data this exposes. Should be unique across selectors."
)
String id() default ID;
}
} |
Beta Was this translation helpful? Give feedback.
-
Many thanks for your answers. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am setting ASC for a project.
I am not finding how I can setup the specific path to open details for video type asset.
I understand that this setup is used to generate url
appending the filetype like /video to the end.
but for a mp4 file i am trying i dont see it happened.
where would i configure the path properly?
my mp4 is going directly to the parent details as config'ed in the screenshot.
but i wanted to go to /video page.
any help is appreciated.
thanks.
l
Beta Was this translation helpful? Give feedback.
All reactions