0

First, this is for Swift 3. I am creating a container app that simply serves a website.

The problem is that everything comes back fine and works, but the images are not showing. When debugging, it looks like the problem is that the webview isn't accepting images from an asp app site that uses a relative path to hit a .net api endpoint within the app. The image is served with the following tag:

<img src="api/Answers/Image/1006" class="panel-image" alt="">

All other functionality and data is coming back fine. The website works perfectly fine on all standard web browsers including safari. Any ideas on how to fix this.

2 Answers 2

1

You would think the webview would understand how to handle a relative url for an img tag... Adding protocol and host of the path to the api should solve your problem though.

If you are injecting the HTML, try something along the lines of this:

'<img src='window.location.protocol + '//' + window.location.host + '"/api/Answers/Image/1006" class="panel-image" alt="">'

Or... if you are setting it via id:

var img = document.getElementById("ImageId");
img.src = window.location.protocol + '//' + window.location.host + '/api/Answers/Image/1006';
Sign up to request clarification or add additional context in comments.

Comments

0

Allen's answer was insightful on another nature of setting up a source, but I found that the back end developer for the site accidentally set the image api to require authentication. The odd thing is that this authentication didn't trigger on any device other than the ipad app. Even the browser didn't request authentication. Removing authentication on the image api fixed the problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.