GithubHelp home page GithubHelp logo

mtdurlpreview's Introduction

#MTDURLPreview

Delight your users with simple URL previews for your iOS app.

MTDURLPreview parses the HTML content of a given URL and tries to find a suitable image and the title/domain of the URL. If you have ideas for improvement (e.g. better image heuristic), please hit me up on Twitter.

MTDURLPreview

Credits

MTDURLPreview was created by Matthias Tretter (@myell0w) and extracted from the beautiful reddit client Biscuit for reddit.

Biscuit for reddit

License

MTDURLPreview is available under the MIT license. See the LICENSE file for more info.

mtdurlpreview's People

Contributors

myell0w avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mtdurlpreview's Issues

Crash occurs on iPhone 5s

When using MTDURLPreview on an iPhone 5s there is crash that is reproducible. It doesn't occur on a 5 or 4s. In my project, SDWebImage is included in my workspace as well.

CODE SNIPPET

//viewWillAppear snippet

    __weak typeof(self) weakSelf = self;

    [MTDURLPreview loadPreviewWithURL:webURL
                           completion:^(MTDURLPreview *preview, NSError *error){

                             __strong __typeof(weakSelf)strongSelf = weakSelf;

                             [strongSelf.previewView setTapActionWithBlock:^{

                               CPLWebViewViewController *webController = [[CPLWebViewViewController alloc] initWithURL:webURL.absoluteString webTitle:preview.title];

                               [weakSelf.navigationController pushViewController:webController animated:YES];
                             }];

                             CGFloat xCoordinate = CGRectGetMinX(strongSelf.profileImageView.frame);
                             CGFloat yCoordinate = CGRectGetMaxY(strongSelf.contentLabel.frame) + 10.0f;
                             CGFloat width       = CGRectGetWidth(strongSelf.view.frame) - 10.0f;
                             CGFloat height      = 0.0f;

                             /**
                              * The content label is empty so we'll just adjust based
                              * on the image view
                              */

                             if (CGRectGetHeight(strongSelf.contentLabel.frame) == 0) {
                               yCoordinate = CGRectGetMaxY(strongSelf.profileImageView.frame) + 10.0f;
                             }

                             CGRect previewFrame = CGRectMake(xCoordinate,
                                                              yCoordinate,
                                                              width,
                                                              height);
                             strongSelf.previewView.frame = previewFrame;

                             [strongSelf.view addSubview:strongSelf.previewView];

                             [strongSelf.previewView setFromURLPreview:preview];
                           }];
  }

STACK TRACE

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x000000019366c0b8 objc_retain + 24
1  Crowdplace                     0x00000001000bb20c -[UIImageView(WebCache) setImageWithURL:placeholderImage:]
2  Crowdplace                     0x00000001000b04a8 -[MTDURLPreviewView setFromURLPreview:] (MTDURLPreviewView.m:145)
3  Crowdplace                     0x00000001000ab358 __46-[CPLPostDetailViewController viewWillAppear:]_block_invoke (CPLPostDetailViewController.m:160)
4  libdispatch.dylib              0x0000000193c2c014 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x0000000193c2bfd4 _dispatch_client_callout + 16
6  libdispatch.dylib              0x0000000193c2f1dc _dispatch_main_queue_callback_4CF + 336
7  CoreFoundation                 0x000000018710ac2c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8  CoreFoundation                 0x0000000187108f6c __CFRunLoopRun + 1452
9  CoreFoundation                 0x0000000187049c20 CFRunLoopRunSpecific + 452
10 GraphicsServices               0x000000018cd31c0c GSEventRunModal + 168
11 UIKit                          0x000000018a17afdc UIApplicationMain + 1156
12 Crowdplace                     0x0000000100099600 main (main.m:16)
13 libdyld.dylib                  0x0000000193c47aa0 start + 4

Not getting url thumbnail image

Code Snippet:

[MTDURLPreview loadPreviewWithURL:[NSURL URLWithString:@"http://www.skype.com/en/"]
completion:^(MTDURLPreview *preview, NSError *error){

                          [self.imgPreview setFromURLPreview:preview];

                           NSLog(@"check the image path %@",preview.imageURL);
                       }];

I am unable to fetch thumbnail image for the url.
Please provide me inputs here

Thanks in advance

MTDURLPreview doesn't respect "Content-Type" charset

Pages which are encoded with non-UTF8 encoding are shown incorrectly especially for languages having several encoding usages in a country.
For example, Russia has at least 6 different charsets for a text encoding:
Windows CP1251, DOS-866, DOS-855, KOI8-R, ISO-8859-5, Cyrillic Mac
Each one has its own encoding charset.
It should be respected by detecting "Content-Type" header and meta http-equiv="Content-Type"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.