How do I use relative http urls for Xaml images - image

I have a need to treat an image in XAML as a special case and have it download the image using the relative HTTP URL and not the relative DLL path. But I cannot seem to get that to work properly. I've tried the pack URL, but it seems to ignore it. None of these appear to work.
<Image Source="pack://siteoforigin:,,,/images/logo.png" />
<Image Source="~/images/logo.png" />
<Image Source="/images/logo.png" />
I would simply like these to work like ordinary HTML img src. I know I can do this in code, but I'm hoping to avoid that if I can.

I finally found a way to get this to work. My xap file is loaded from /ClientBin/, so the resulting URLs for the download are actually this:
/ClientBin/images/logo.png.
Once I realized that was happening, I was able to add URL map to my web.config and an HttpHandler to redirect the image download where I need it to go.

Related

Error displaying images in subdomain using laravel 5.3

I have successfully deployed my laravel project to shared hosting (cPanel) and all seems to be working apart from the images. The images stored directly on the server e.g. logo.png don't show up and yet css files in the same public directory show up.
When I try to view the image directly via its URL, I still can't access it and gives me an error of "The image "http://..." cannot be displayed because it contains errors.
Could you please advise? Thanks in advance
Updated:
I have tried several alternatives which work locally but not when I upload.
< img src="/img/logo.png" width="100" />
< img src="{{ asset('/img/logo.png') }}" width="100" />
None of the above works and even when I try to access it via http://sub.domain.com/img/logo.png . It gives the error above
It turns out that the problem wasn't with the RewriteRule but rather the ftp client uploading the images with ASCII format. Laravel doesn't seem to pick those images so I re-ftped them with binary format and everything is working fine.
I hope this can help someone else.

Spring image URL is not resolved in ipad

I'm using spring tiles framework to display the screens where I have mentioned spring url for image path by giving like ${baseurl}.
It is working fine in both Mozilla and safari browsers desktop.when I try to access the application by ipad browser(safari)there i'm not able to see my image getting loaded.
Please help me on this.
I highly doubt that the browser affect the way tiles work.
I can imagine that the way you referere to an image url in you jsp is wrong. The recomended way is somethink like that:
<c:url value="/imagefolder/myimage.png" var="imgUrl" />
<img src="${imgUrl}" width="64" height="64" />

Absolute url from relative path in an ascx file?

Imagine I have an image hosted at http://www.mypage.com/content/images/myimage.png and I want to display it on my webpage. In my ascx file is the following:
<img runat="server" id="ImgLarge" class="myimage" src="../content/images/myimage.png" />
The only problem is that this image doesn't print. I believe the fix is to have the image use the absolute URL but I'd rather not use http://www.mypage.com/content/images/myimage.png and instead use something like src=#Url.Absolute('~/images/solar-panel.png').
Does this work in ascx files? If not, is there an alternative? I've only ever done this in my cshtml files. Thanks!
Is the image a part of the project? Typically you would have your user controls in one folder and image controls in another (same level). If this is the case, you would have a url like this:
<asp:ImageButton runat="server" ID="ImageButton2" OnClick="sortApproved_Click" ImageUrl="~/images/down.png" />
Other wise, if you want to diagnose whats going on, look at the rendered web pages source. What does the url look like?

MVC 3 Won't Serve Content files from Areas subfolder

I have an MVC3 application with a couple of areas and a portable area as well (using MVCContrib)
Normally, I keep all my content files under ~/Content and my scripts under ~/Scripts.
However, I am building a fairly complex webclient to another service on my site and I want to organize those javascript and image files (LOTS of image files and resources) under the Area's folder structure, which looks something like this, under ~/Areas/WebClient
Content
css
fonts
images
js
Controllers
Models
Views
I have a resource aggregator controller (one of my portable areas) that is able to reach into the CSS/JS folders just fine to provide that content. However, the CSS files reference the images/fonts folders directly and all of those links show up broken. I have double and triple checked the paths and made sure everything was right but I still get 404 errors.
As far as I know MVC3 is supposed to ignore routing so long as there's a static file there. Also, as far as I know, only the App_* folders enjoy special protection. What am I missing? I'd rather not mix in my images and resources with my main application if I can at all avoid it.
As an example: http://localhost/Areas/WebClient/Content/images/knownimage.png will not work, but should, as it exists!
So after some sleep and, more importantly, stepping away from the problem I remembered that MVC does in fact offer you protection from people downloading views directly, which led me to remember the Web.config file required in the Areas folder. Sure enough, there's an httphandler that basically sends all requests to the FileNotFound handler.
All I had to do was drop a web.config file in the content folder I wanted to expose with the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler" />
</handlers>
</system.webServer>
</configuration>
Problem solved.

Image display codeigniter fails

I can upload image to the directory but can not disply it on the page.
Tried using static html code and codeigniter img() function, both are not working.
Here is my code:
<image src="./applications/views/uploads/image.jpeg" />
and
$this->output->set_header("Content-Type: image/jpeg");
$data['image'] = $this->load->file('../uploads/taurus.jpeg');
the first code shows me broken image the second one shows Unable to load the requested file: taurus.jpeg
<image src="./applications/views/uploads/image.jpeg" />
By default, CodeIgniter denies access to the application folder which is why I suspect this isn't working.
$this->output->set_header("Content-Type: image/jpeg");
$data['image'] = $this->load->file('../uploads/taurus.jpeg');
I suspect this isn't working because your path is incorrect. The path is relative to the index.php file in the root of your application, not the file this code is in. Secondly, $this->load->file() sends to file contents to the browser so this wouldn't work anyway.
A solution would be to move your uploads folder to a web accessible location. For example, place the uploads folder into the root of your application - the same folder as your index.php file. Then you can display your image like this:
<image src="/uploads/image.jpeg" />
Just get rid of the dot (.) in the URL so your src url reads: "/applications/views/uploads/image.jpeg"

Resources