<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to get web resouces images defined in a CSS file?</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file</link><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;In an HTML dialog, if I use either of the following instructions for importing a style: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;h:outputStylesheet name="portlet/css/presential.css"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;link rel="stylesheet" href="#{resource['portlet/css/presential.css']}" type="text/css"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the CSS file is loaded (see line #1 below) with the request attribute "&lt;strong&gt;?ln=xpertivy-14-WebContent&lt;/strong&gt;".&lt;/p&gt;
&lt;p&gt;Unfortunately, it cannot find the images defined in the CSS (see 2 last lines).
Notice that the request attribute above is not appended to the image request.
&lt;img alt="alt text" src="/upfiles/2013-11-18_17_14_13-screenshot.png"&gt;&lt;/p&gt;
&lt;p&gt;This could be important because if I manually request the following URL:
&lt;strong&gt;&lt;code&gt;http://localhost:8082/ivy/faces/javax.faces.resource/portlet/images/clock24.png?ln=xpertivy-14-webContent&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I can successfully get the clock24.png image.&lt;/p&gt;
&lt;p&gt;Is it actually a bug, or is there a particular way to do it?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 07 Nov 2018 03:50:15 -0500</lastBuildDate><item><title>Comment by trungdv on Peter Stöckli's answer</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#3539</link><description>&lt;p&gt;hi &lt;a href="https://answers.axonivy.com/users/5/peter-st%C3%B6ckli"&gt;&lt;a href="https://answers.axonivy.com/users/5/peter-st%C3%B6ckli"&gt;@Peter Stöckli&lt;/a&gt;&lt;/a&gt; ♦
Can i apply same for js file? it's seem not work.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">trungdv</dc:creator><pubDate>Wed, 07 Nov 2018 03:50:15 -0500</pubDate><guid>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#3539</guid></item><item><title>Comment by Nikel Weis on Peter Stöckli's answer</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#93</link><description>&lt;p&gt;You can use a regular expression to make this less error prone - something like url((.+)) [search string] and url("#{resource['img:\1']}") [replace string]. Whereas 'img' would be the target folder like Heinrich Spreiter suggested in his tutorial about using ThemeRoller for Xpert.ivy: &lt;code&gt;http://blog.xpertivyhacker.ch/search/label/ThemeRoller&lt;/code&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nikel Weis</dc:creator><pubDate>Tue, 19 Nov 2013 13:51:55 -0500</pubDate><guid>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#93</guid></item><item><title>Comment by A1234 on Peter Stöckli's answer</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#92</link><description>&lt;p&gt;This solution is valid if we use an external CSS file whose content is under control.&lt;/p&gt;
&lt;p&gt;However, if an external 3rd-party JavaScript library or framework is used, it often comes with CSS style sheets and referenced images.&lt;/p&gt;
&lt;p&gt;If the developer puts these resources in the WebContent folder, I suppose everything will work fine, except for the images referenced by the CSS style sheets. Unless you edit them by hand to fix all image paths located in the 3rd-party style sheets, which is laborious and error-prone.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">A1234</dc:creator><pubDate>Tue, 19 Nov 2013 13:21:22 -0500</pubDate><guid>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#92</guid></item><item><title>Comment by Nikel Weis on Peter Stöckli's answer</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#90</link><description>&lt;p&gt;Had to add url("#{resource['portlet/images/clock24.png']}") - but works like a charm. Thanks. :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nikel Weis</dc:creator><pubDate>Tue, 19 Nov 2013 10:12:48 -0500</pubDate><guid>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#90</guid></item><item><title>Answer by Peter Stöckli</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file/89</link><description>&lt;p&gt;It should be possible to access images in the webContent folder if you reference the image similar to this in the .css file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.my-icon
{
   background-image:url(#{resource['portlet/images/clock24.png']}) !important;
}
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Stöckli</dc:creator><pubDate>Tue, 19 Nov 2013 10:01:12 -0500</pubDate><guid>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file/89</guid></item><item><title>Answer by Nikel Weis</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file/88</link><description>&lt;p&gt;It does not seem to be possible to access images within the webContent-folder from an externally loaded style-sheet. Maybe as a workaround: If you are using a PageTemplate, just put your style-definitions using images there. The code would be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; url("#{ivy.html.wr('task_abort.png')}")
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;...whereas the prefered way is to put in the CMS.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; url("#{resource['ivy-cms:Images/image']}")
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nikel Weis</dc:creator><pubDate>Tue, 19 Nov 2013 09:09:08 -0500</pubDate><guid>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file/88</guid></item><item><title>Comment by Flavio Sadeghi on A1234's question</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#87</link><description>&lt;p&gt;hi &lt;a href="/users/22/adriano-labate/"&gt;&lt;a href="/users/22/adriano-labate/"&gt;@adriano&lt;/a&gt;&lt;/a&gt;-labate, it was the http-link. It's a known issue. Just putting two ` round the link and it works...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Flavio Sadeghi</dc:creator><pubDate>Mon, 18 Nov 2013 19:43:54 -0500</pubDate><guid>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#87</guid></item><item><title>Comment by A1234 on A1234's question</title><link>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#86</link><description>&lt;p&gt;Hey, where's my question content ?? it is there if I edit, but not shown when published :-(&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">A1234</dc:creator><pubDate>Mon, 18 Nov 2013 17:22:02 -0500</pubDate><guid>https://answers.axonivy.com/questions/85/how-to-get-web-resouces-images-defined-in-a-css-file#86</guid></item></channel></rss>