Last active
December 12, 2024 19:18
-
-
Save prince-neres/6699596f5e1faa6e6f2ba9bde3fee203 to your computer and use it in GitHub Desktop.
Código freemarker para pegar url de imagens de conteúdos web no liferay
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
<#-- | |
Configurações para habilitar serviceLocor localizar classes java | |
não instanciadas por BaseService e BaseLocalService | |
Setar varável em `portal-ext.properties` | |
template.engine.service.locator.restrict=false | |
--> | |
<#assign | |
dlURLHelper = serviceLocator.findService("com.liferay.document.library.util.DLURLHelper") | |
dlAppService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLAppService") | |
journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") | |
groupId = 0 | |
articleId = "0" | |
article = journalArticleLocalService.getArticle(groupId, articleId) | |
docXml = saxReaderUtil.read(article.getContentByLocale(locale.toString())) | |
image = docXml.valueOf("//dynamic-element[@name='imagemDeCapa']/dynamic-content") | |
imageProps = dlAppService.getFileEntry(image?eval.fileEntryId?number) | |
imageUrl = dlURLHelper.getPreviewURL(imageProps, imageProps.getFileVersion(), themeDisply, "") | |
> | |
<div> | |
<p> | |
${imageUrl} | |
</p> | |
<img src="${imageUrl}"> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment