Re: [Cppcms-users] How to specify the file path or image in web page
Brought to you by:
artyom-beilis
From: kpeo <sla...@ya...> - 2011-08-05 10:09:44
|
<div>Hello,</div><div> </div><div><span lang="en"><span>maybe it</span> <span>will help:</span></span></div><div> </div><div>when you put <img src="/resources/images/logo.gif"/> - web-frontend use url with current URL (http://site.org/resources/images/logo.gif)</div><div>and get file relatively of your document-root in web-frontend (nginx/lighttpd/apache - usually /var/www) - so path is: /var/www/resources/images/logo.gif</div><div> </div><div>As for code:</div><div>You can use project.resource from configuration:</div><div>{</div><div> "project" : {</div><div> "resource" : "/resource",</div><div> }</div><div>}</div><div> </div><div>in code of page:</div><div>void page::init(content::page &c){</div><div>c.resource = settings().get<std::string>("project.resource");</div><div>}</div><div> </div><div>in template:</div><div><img src="<% resource %>/img/test.jpg" /></div><div> </div><div>so your final path is - http://project.org/resource/img/test.jpg (it can be overwrited by web-frontend like nginx/lighttpd to /img/test.jpg)</div><div> </div><div>directory /resource must exist in your document-root of web-frontend.</div><div> </div><div>in css it may be like (/resource/css/style.css):</div><div>background: white url(../img/test.jpg) no-repeat;</div><div>05.08.2011, 12:50, "陈抒" <csf...@gm...>:</div><blockquote>Hello,<div> I want to show some images in my web page ,but I don't know where I should put my image file?</div><div><br /><div> <img src="resources/images/logo.gif"/></div><div>Any document or example?</div><br />陈抒 <br />Best regards<br /><a href="http://blog.csdn.net/sheismylife" target="_blank">http://blog.csdn.net/sheismylife</a></div><p>------------------------------------------------------------------------------<br />BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA<br />The must-attend event for mobile developers. Connect with experts. <br />Get tools for creating Super Apps. See the latest technologies.<br />Sessions, hands-on labs, demos & much more. Register early & save!<br /><a href="http://p.sf.net/sfu/rim-blackberry-1">http://p.sf.net/sfu/rim-blackberry-1</a></p><p>_______________________________________________<br />Cppcms-users mailing list<br /><a href="mailto:Cpp...@li...">Cpp...@li...</a><br /><a href="https://lists.sourceforge.net/lists/listinfo/cppcms-users">https://lists.sourceforge.net/lists/listinfo/cppcms-users</a></p></blockquote> |