'ios share extension - how to get image URL?

I am writing an action extension to transform an image URL and copy to clipboard by clicking the share button of an image on a webpage in Safari.

I created an action extension in Xcode without UI.

In javascript preprocessing script action.js, I can get the URL and title of the whole page.

    run: function(arguments) {
        
        arguments.completionFunction({
            "URL" : document.URL,
            "title": document.title
        })
    },

And that works for the share button of the whole webpage.

But how can I get the URL of the image that is pushed one?



Solution 1:[1]

When you use from URL, its better to use from :

  pod 'SDWebImage'

this is better because of cache

you can Set your URL string with below code:

libraryImageView.sd_setImage(with: URL(string: "your URL string"),
                                  placeholderImage: UIImage(named: Image.placeholder.rawValue))

after that you can get URL with below code:

libraryImageView.sd_ImageURL

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1