-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageEngineUrlStrategy.java
36 lines (30 loc) · 1.16 KB
/
ImageEngineUrlStrategy.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.imageengine.media.url.impl;
import de.hybris.platform.media.MediaSource;
import de.hybris.platform.media.storage.MediaStorageConfigService;
import de.hybris.platform.media.url.impl.LocalMediaWebURLStrategy;
import de.hybris.platform.util.Config;
import de.hybris.platform.util.MediaUtil;
public class ImageEngineUrlStrategy extends LocalMediaWebURLStrategy
{
final String mediaHostName = Config.getString("media.folder.images.hostname", "");
@Override
public String getUrlForMedia(final MediaStorageConfigService.MediaFolderConfig config, final MediaSource mediaSource)
{
final String urlForMedia = super.getUrlForMedia(config, mediaSource);
return appandHostName(urlForMedia);
}
@Override
public String getDownloadUrlForMedia(final MediaStorageConfigService.MediaFolderConfig config, final MediaSource mediaSource)
{
final String downloadUrlForMedia = super.getDownloadUrlForMedia(config, mediaSource);
return appandHostName(downloadUrlForMedia);
}
private String appandHostName(final String urlForMedia)
{
if (!mediaHostName.isEmpty())
{
return MediaUtil.removeTrailingFileSepIfNeeded(mediaHostName) + urlForMedia;
}
return urlForMedia;
}
}