access the folder image docroot - image

I have a picture in glassfish docroot folder and display it but I need a relative path.
My code is as follows
<h:graphicImage value="/#{detalle.path} />
And it produces the following result: 'localhost:8080/Gestion/image.png'
I need something like 'localhost:8080/image.png'
Note: Path is the image name.
How do I get this? Thanks in advance

The <h:graphicImage value> implicitly prepends the context path in the URL. What you want is not possible with <h:graphicImage>. If you need to point to an image which is not part of the webapp, then just use plain HTML <img> instead.
<img src="/#{detalle.path}" />

Related

Get the image path in fluid

in my fluid template I create an image with
<f:media file=" {post.teaserAssetsWide.0}" width="708" height="398" />
Is there a way to get just the path of the image like "domain.com/path.jpg" ?
Edit: {post.teaserAssetsSquare.0.originalResource.publicUrl} is the relative path for the image. But the domain is still missing
I think you need to just add this paths in your fluid template like below. you don't need to add your domain name. You domain name will be automatically added in your paths.
Just added absolute = '1' for full paths.
<f:image src="{object.image.originalResource.publicUrl}" alt="{object.image.originalResource.title}" width="640" height="291" treatIdAsReference="1" />
Or try to below for absolute paths.
<f:image image="{post.teaserAssetsSquare.0}" title="{post.teaserAssetsSquare.0.originalResource.title}" absolute="1" />
For get just image paths.
<f:uri.image image="{post.teaserAssetsSquare.0}" width="400" height="375" absolute="1" />

Thymeleaf parse text and execute in-text expressions

I have text string, that contains links, for example, like <a th:href="'someLink'">Download</a> .
I need to process that text and replace th:href="'someLink'" with correct links to show text with Download.
The text with links is stored in variable textThatContainsLinks.
My code to show text is <div th:utext="${textThatContainsLinks}">. I also tried to use preprocessing like <div th:utext="${__textThatContainsLinks__}">.
Currently this code shows links not as I expected, but non-preprocessed, ie, output is <a th:href="'someLink'">Download</a> now.
How to pre-process expressions in text, before showing it?
Thank you very much!
Take the context path and directly attach it to the relative path of a pure html5 attribute e.g LINK, <img src="/contextPath/relative/path/image.jpg" width="50" height="50" alt="logo"/>.
Notice how simple the accessibility to the resource is: /contextPath/relativePath, so the most important path there is the relative path. This is similar to Thymeleaf was unable to render <img> tag when sent from database table. I observed that once thymeleaf's namespace th: qualifies a href or src attribute that resides inside a text/String the absolute path is not properly resolved.

How to link an URL inside the them from the Diazo rules file?

If an URL to a image is set in a HTML template, then the URL is updated to reference files inside the theme folder. For example,
<img src="image.png" />
is replaced by:
<img src="http://localhost:8080/mysite/++theme++mytheme-theme/image.png" />
However, if I write following Diazo rule:
<replace css:content="#some-class">
<div id="#some-class"><img src="image.png" /></div>
</replace>
the URL of the image is not update. How can I write Diazo rules where the image gets correctly referred. I want to refer this image in the template HTML file with <img src="path/image.png">. However it is not clear what to put instead of path. I notice that path cannot be an absolute path because it depends of the site domain. Also, it cannot be a relative path because it depends on the path of each page in the site. May be it would be useful to have an specific keyword to reference the theme folder. For example, <img src="$themeFolder/image.png">. Exists such keyword?
You may create XSLT parameters in your theme's manifest.cfg file. Just add a stanza like:
[theme:parameters]
theme_base_url = string:${portal_state/portal_url}/++theme++mytheme-theme/
Then you may use it in your rules file:
<replace css:content="#some-class">
<div id="#some-class">
<img><xsl:attribute name="src"><xsl:value-of select='$theme_base_url' />image.png</xsl:attribute></img>
</div>
</replace>

Custom image in footer (Prestashop)

I have a small question. I am using prestashop, and would like to add image in my footer. I am trying to add img tag in footer.tpl
<img src="/htdocs/themes/warehouse/img/logo_btm.png" alt="logo" />
but instead of picture i have question mark.
you use relative path
instead of relative path use full url to your image like
http://domain.com/link/to/image.jpg
You have to use smarty global var, put the image in your theme's image folder and use this syntax
<img src="{$img_dir}logo_btm.png" alt="logo" />

grails images absolute path

I have this image in my header template <img src="images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
When the template is used from a gsp file inside the 'main' directory, the image is loaded. Although, if I have the same template being used inside a gsp file inside a controller, the image is not loaded. I have tried to change this:
<img src="images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
to this:
<img src="../images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
and it works, but now the image in the other page don't. Any idea to solve the problem? I know the key must be absolute path. But i've done some searches and found nothing.
You can put your images in resource folder (for example, in YOUR_PROJECT/web-app/images) then access it in gsp by resource tag. By this way you won't have the absolute path problem.
For a concrete example, you can refer this question.
Try "${application.contextPath}/images/slide-1.jpg". It's a semi-absolute path that will work in any of your deployment environments.

Resources