Open rizwan95 opened 4 years ago
Hi @rizwan95, Currently the image download is handled by a simple download task and only a base URL can be configured (typically for images using relative links).
Could you provide more information about your use case, and about the type of URLRequest customization you would need?
@jlj Sometimes we might need to send additional headers like user-agent and authorization headers for downloading images from authenticated services. So, it would be very helpful if there is a way to send them.
@jlj Any update on this?
A possible option could be to add a imageURLSession
property of type NSURLSession
in CMAttributedStringRenderer
. If set, this imageURLSession
property would then be used to retrieve every remote image referenced by the current document.
At creation time, the imageURLSession
property could receive any desired NSURLSessionConfiguration
, providing thus a high level of customizability to image download.
@rizwan95 Would this solution respond to your needs?
@jlj : Yes, that would solve the problem! Infact it will open up a lot of opportunities for customizability.
@rizwan95 I have implemented this imageURLSession
property change in my CocoaMarkdown fork at https://github.com/jlj/CocoaMarkdown/tree/5512cf52d292288e1748e7bde097e5b28a7e52b6
Can you test it with your specific server configuration? If it is ok, I will issue a pull request.
@jlj Yes sure!
@rizwan95 Have you made tests of this imageURLSession
property?
Not yet, I will test it today and let you know @jlj Sorry for the delay!
@rizwan95 Any test result?
Hi @jlj I tested the given patch. It is not rendering basic markdown content itself. :( I suppose something is broken..
Hi, is there any way to add URLRequest in the inline image download method? @indragiek