How to get thumbnails from any url in iOS?

In both chat applications, in social applications there is a function when we insert a link to a text view, giving us a sketch from this URL, enter image description here

Can this be done in an iOS application. If so, can I do this?

+7
ios objective-c
source share
4 answers

I finally did it with MTDURLPreview on github

Using

#import "MTDURLPreview.h" [MTDURLPreview loadPreviewWithURL:@"url here" completion:^(MTDURLPreview *preview, NSError *error) { NSLog(@"Image URL : %d", [preview.imageURL isEqual:[NSNull null]]); NSLog(@"Content : %@", preview.content); NSLog(@"Title : %@", preview.title); }]; 

Hope your problem is resolved.

+1
source share

I would analyze the contents of html and try to find links to .png, jpg files, etc. Then check the resolution to exclude very small images or those indicated as background in css. As a result, the user will receive a list of filtered images, for example, in the screenshot that you attached.

As an analyzer you can use https://github.com/nolanw/HTMLReader

+8
source share

You can use PhoneGap, and for this to work automatically, you need to introduce some algorithms to view the HTML source, for example

 <meta property="og:title" content="The Rock" /> <meta property="og:type" content="video.movie" /> <meta property="og:url" content="http://www.imdb.com/title/tt0117500/" /> <meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" /> 
+2
source share

Pages like Facebook use OpenGraph information from web pages to create thumbnails of links. OpenGraph attributes describe the object represented on the web page. OpenGraph data is stored in meta tags, as shown in A.Krasniqi's answer:

 <meta property="og:title" content="The Rock" /> <meta property="og:type" content="video.movie" /> <meta property="og:url" content="http://www.imdb.com/title/tt0117500/" /> <meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" /> 

These meta tags are prefixed with og .

The main attributes of OpenGraph:

  • og: title (object title)
  • og: type (Object type, e.g. video.movie)
  • og: url (permanent, canonical URL for this object)
  • og: image (Image representing the page)

Other tags include:

  • og: description (object description)
  • og: video
  • og: audio

All OpenGraph options are documented here.

You can use NSXMLParser , but others have implemented OpenGraph parsers. (Just google "iOS OpenGraph parser")

+2
source share

All Articles