Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(request) : be able to load remote images #12

Open
y0hnn opened this issue Aug 23, 2012 · 8 comments
Open

(request) : be able to load remote images #12

y0hnn opened this issue Aug 23, 2012 · 8 comments

Comments

@y0hnn
Copy link

y0hnn commented Aug 23, 2012

Hi,
It would be awesome if we can load images remotely :) ! I tried to but it did not work. Maybe you can edit my code to implement it easier in the repo ? look at this : stackoverflow.com/questions/11927942/ios-core-text-loosing-context-when-drawing-image-inside-a-block

@dourgulf
Copy link

I have do some modify to support dynamic loading remote images, but it add a depend on SDWebImage(maybe rewrite the loading progress),
add it to the processText method
else if (currentSupernode.isImage) {
//replace active string with emptySpace
NSRange elementContentRange = NSMakeRange(currentSupernode.startLocation, tagRange.location - currentSupernode.startLocation);
NSString * elementContent = [processedString substringWithRange:elementContentRange];

                UIImage *img = nil;
                if ([elementContent hasPrefix:@"http"]) {
                    // image from http
                    // try to load from cache
                    img = [[SDImageCache sharedImageCache] imageFromKey:elementContent];
                    if (!img) {
                        // not in cache, load it from URL
                        img = [UIImage imageNamed:@"loading"];
                        NSURL *imgURL = [NSURL URLWithString:elementContent];
                        NSLog(@"loading image %@", elementContent);
                        // download it
                        id successblock = ^(UIImage *image) {
                            NSLog(@"loaded %@", elementContent);
                            currentSupernode.image = image;
                            currentSupernode.style.leading = image.size.height;
                            [self didMakeChanges];
                            if ([self superview]) [self setNeedsDisplay];
                        };
                        id failedblock = ^(NSError *error) {
                            NSLog(@"load image failed %@", elementContent);
                        };
                        [[SDWebImageManager sharedManager] downloadWithURL:imgURL
                                                                  delegate:self
                                                                   options:0
                                                                   success:successblock
                                                                   failure:failedblock];
                    }
                }
                else
                {
                    img = [UIImage imageNamed:elementContent];
                }
                if (img) {
                    currentSupernode.image = img;
                }
                else {
                    NSLog(@"FTCoreTextView :%@ - Couldn't find image '%@' in main bundle", self, NSStringFromRange(elementContentRange));
                    [processedString replaceCharactersInRange:tagRange withString:@""];
                }

@ghost
Copy link

ghost commented Sep 2, 2012

I modified with your code, but get an error, for this line: currentSupernode.image = image; and currentSupernode.image = img; the error: Property 'image' not found on object of type 'FTCoreTextNode *'

can i remove original "else if (currentSupernode.isImage){ ....} or not?

@cescofry
Copy link
Contributor

cescofry commented Sep 2, 2012

There are specifics tags to refer to for special instances like images and
unordered lists. They are listed in the header file.
Fra.

Francesco Frison
Cescofry@gmail.com
+447766561587
From my iPhone

On 2 Sep 2012, at 13:41, KommyKT notifications@github.com wrote:

I modified with yout code, but get an error, for this line:
currentSupernode.image = image; and currentSupernode.image = img; the
error: Property 'image' not found on object of type 'FTCoreTextNode *'


Reply to this email directly or view it on
GitHubhttps://github.com//issues/12#issuecomment-8221559.

@dourgulf
Copy link

the image property is UIImage * type which add to FTCoreTextNode class.
(BTW, I have do much modification for this project, but I don't how to push
my work.)

2012/9/2 KommyKT notifications@github.com

I modified with yout code, but get an error, for this line:
currentSupernode.image = image; and currentSupernode.image = img; the
error: Property 'image' not found on object of type 'FTCoreTextNode *'


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-8221559.

@ghost
Copy link

ghost commented Sep 19, 2012

Yout can send the modified code by e-mail or any filesharing portal.

On Sep 19, 2012, at 8:19 AM, dourgulf notifications@github.com wrote:

the image property is UIImage * type which add to FTCoreTextNode class.
(BTW, I have do much modification for this project, but I don't how to push
my work.)

2012/9/2 KommyKT notifications@github.com

I modified with yout code, but get an error, for this line:
currentSupernode.image = image; and currentSupernode.image = img; the
error: Property 'image' not found on object of type 'FTCoreTextNode *'


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-8221559.


Reply to this email directly or view it on GitHub.

@cescofry
Copy link
Contributor

Or you can do a push request on github.
Francesco.

Francesco Frison
Mobile: +447766561587 [UK]
Mail: cescofry@gmail.com
Skype: ziofritz
--- www.ziofritz.com ---

On 19 Sep 2012, at 11:18, KommyKT notifications@github.com wrote:

Yout can send the modified code by e-mail or any filesharing portal.

On Sep 19, 2012, at 8:19 AM, dourgulf notifications@github.com wrote:

the image property is UIImage * type which add to FTCoreTextNode class.
(BTW, I have do much modification for this project, but I don't how to push
my work.)

2012/9/2 KommyKT notifications@github.com

I modified with yout code, but get an error, for this line:
currentSupernode.image = image; and currentSupernode.image = img; the
error: Property 'image' not found on object of type 'FTCoreTextNode *'


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-8221559.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub.

@dourgulf
Copy link

I have open a new repository on github. Hope it will help you.

On 2012-9-19, at 下午6:18, KommyKT notifications@github.com wrote:

Yout can send the modified code by e-mail or any filesharing portal.

On Sep 19, 2012, at 8:19 AM, dourgulf notifications@github.com wrote:

the image property is UIImage * type which add to FTCoreTextNode class.
(BTW, I have do much modification for this project, but I don't how to push
my work.)

2012/9/2 KommyKT notifications@github.com

I modified with yout code, but get an error, for this line:
currentSupernode.image = image; and currentSupernode.image = img; the
error: Property 'image' not found on object of type 'FTCoreTextNode *'


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-8221559.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub.

@PKPranav
Copy link

plz upadate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants