JxBrowser. Loading local recources - jxbrowser

Is it possible in JxBrowser to reference resources (images, scripts, etc) from class path or local files?
Tried several approaches:
<img src="image.png"/>
<img src="file://image.png"/>
<img src="file://full/path/image.png"/>
none of these were working

You can pass the following Chromium switches:
BrowserPreferences.setChromiumSwitches(
"--disable-web-security",
"--allow-file-access-from-files");
As for the approach, this is an example of the working one:
<img src="file:///C:/folder/0001-1.jpg"/>

Related

Images Not Appearing Asp.Net Core

I am attempting to use imported images in my .Net Project. I have placed the images in the images folder and they all have a plus sign and say "Pending add" next to them.
I'm not sure if this is the error or how I am referencing the images. I reference the image using the following code.
<img class="block" id="u730_img" src="Images/green9-crop-u730.jpg?crc=200722682" alt="" width="1529" height="659"/>
The image name is correct, but I'm not sure if that is the appropriate path. My folder structure is below. The file being used is LoginBody.cshtml and the image is in the images folder.
I suspect that you're using ASP.NET Core, and in newer version static files under wwwroot folder are served.
Move your images to wwwroot > images
and change your path:
<img class="block" id="u730_img" src="~/Images/green9-crop-u730.jpg?crc=200722682" alt="" width="1529" height="659"/>
Hope this helps !

How to get absolute file system path to an image Symfony2/Twig

I am using Symfony2 with twig to generate HTML, however the HTML I am generating is not intended for a web browser, instead it will be passed to a library that converts HTML to a PDF document.
There are two related issues I am facing.
Issue 1. This PDF will have images included, I don't want these images to be visible directly from the internet (e.g. I don’t want these images to appear under webroot). Usually I put assets in “site/src/path-to-bundle/Resources/public/assets” however, I don't want this image to be visible on the web. Can anyone suggest a good folder to put “assets” in that are not meant to be accessible via the web. (Just trying to be consistent with Symfony2 naming techniques and how other programmers would usually do this)
Issue 2. Since the HTML I am generating is intended for the HTML to PDF generator, it is most practical to refer to images with absolute paths on the file system (web paths or URLs are not suitable in this situation).
For example
<!-- This is the correct HTML code that is needed in this situation -->
<img src="/home/user/absoulte-file-system-path-to/image.png" />
<!-- These are actually incorrect in this situation -->
<img src="assets/image.png" />
<img src="http://www.somedomain.com/assets/image.png" />
I would like to know how to get the absolute path to the image mentioned above (I don’t mind if this is done in the Twig template or in the controller)
in you app/config/config.yml
twig:
globals:
root_path: %kernel.root_dir%
and you can refer to asset with relative path to your root project
<img src="{{ root_path }}/../secret-folder/image.png" />

Umbraco css vs images path

I creating new website using Umbraco(version 6.1.1 with razor) and I am new to Umbraco. My settings panel is like this.
In my Master template I am using my css styling and JavaScripts are like this. And their paths are ok.
<link rel="stylesheet" href="/css/mobile.css"/>
<script src="/scripts/jquery-2.0.2.js"></script>
CSS and scripts path are working. So that's ok.
Now my problem is I want images for my site. I don't know where to put images and what should be the path.
For example:
I tried to upload pictures to Media
In my Master template I tried
<img src="/media/A.jpg" alt="Smiley face" height="42" width="42">
<img src="/media/images/A.jpg" alt="Smiley face" height="42" width="42">
Also in the CSS file
background-image:url('/media/images/A.jpg');
But these are not working. I just trialing them. Actually I don't know the correct way of doing it :(
So where should I store images in Umbraco and how should I locate the path in CSS files and template files ?
Please help!
Thanks in Advance ....
Items stored in the media section will have a path like:
/media/<row_id>/filename.ext
Where <row_id> is literally the id of the row in the database where the media item's information is stored.
One way you can determine the path of the media item is to click on the thumbnail (if it's an image) and copy what is in the address bar.
You can also access the file by id via a macro using xslt or razor. Here's a razor example:
#{
int imageId = 1069;
var media = Library.MediaById(imageId);
<img src="#media.umbracoFile" alt="" />
}
However, this is a content management system, and you will no doubt have end-users managing the content and, therefore, it wouldn't make sense to place design specific images in the media section. A more full-proof approach would be to simply place them in an images folder in the root of your site and use them from there.
Should be as simple as this on your css:
.style { background-image: url(/media/1006530/A.jpg); }
The path you get from the media url with row id (e.g.1006530) in it

Why images inside pipline can't be loaded from views in Rails?

I have a div which have dynamic background based on user-input, so I want to load the background directly from erb file so when I type
<div class="desk" style="background:url(myphoto.png);">
It doesn't work, although it work if I typed this line into css file
so any suggestions what's going on here?
Path is wrong it should be prefixed with "/assets/". You should use asset_path method. Without that additional problems will occur on production when md5 hash will be added at the end of filename. Try this:
<div class="desk" style="background:url(<%= asset_path('myphoto.png') %>);">
More information about that can be found in Rails Guides

Embedding a spark variable to make up a string

Hi new to spark so this should be simple.
I'm converting an old webfoms page to mvc using spark.
I want to use the Base.Application to make up the src of a url
original markup
<img alt="" src="<%= Base.ApplicationPath %>images/screenshots/myImage.jpg" />
I've tried this in spark
<img alt= src=${ Base.ApplicationPath }+">images/screenshots/myImage.jpg" />
but no joy.
How do i do this in spark?
Not sure if you're aware of this, but Spark has a DefaultResourcePathManager that will automatically locate the Site Root if you prefix the resource with a tilde, so this should work just fine, and looks neater.
<img alt="" src="~/images/screenshots/myImage.jpg" />
There's an added bonus to using this technique as well....hold on to your shorts! Without changing your view, simply by making sure you use the tilde convention, you can dynamically redirect requests for your static resources to a content delivery network (CDN) or a completely different location - even an embedded resource inside a Spark Module .dll you compile for dll drop in deployment.
For example, to hook it up to a CDN, all you'll need to do is add the following kind of thing to your Spark Settings:
<resources>
<add match="/content/images" location="http://mycdn.com/youraccount/images"/>
<add match="/content/css" location="http://mycdn.com/youraccount/css"/>
<add match="/content/js" location="http://mycdn.com/youraccount/js"/>
</resources>
...and from then on those resources will be fetched from the new location instead. This is great for scenario testing locally, and the deploying to the cloud later.
Slight tweak of the syntax has sorted it.
<img alt="" src="${Base.ApplicationPath}images/screenshots/myImage.jpg" />

Resources