Adam Kiss Posted January 20, 2012 Share Posted January 20, 2012 Hey all, I'm trying to add dynamically generated Google Chart Image to image field, but... it doesn't work $imgSrc = 'https://chart.googleapis.com/chart?chs=920x200&cht=bvs&chd=t:0,7,0,0,4,0,0,0,0,0,0,1,0,0,0,1,2,0,0,0,7,11,4,0,3,4,2,4,6,1&chds=a&chm=B,eeeeee,0,0,0&chls=3&chco=222222' $page->images->add($imgSrc); It fails with 'Exception: Unable to copy: ' and adds a bunch of data. I've got two questions: How can I affect the filename of the file created [thus add some extension, for instance it's PNG file]. And more importantly, why doesn't this work? I know for a fact that URL adding works. Edit: Actually, this is how I save this: $page->images->removeAll(); $page->images->add($commitsGraphSrc); //it's an URL for google chart API $page->images->add($languagesGraphSrc); //another URL for gchart API $page->save(); Link to comment Share on other sites More sharing options...
Adam Kiss Posted January 20, 2012 Author Share Posted January 20, 2012 Okay, this is me being idiot; if you've tested your images with '&', be sure to switch back to '&'only. Thanks. Link to comment Share on other sites More sharing options...
ryan Posted January 20, 2012 Share Posted January 20, 2012 Hey Adam, we cut out of the conference early and just made it back. There's a few issues with this URL that make it not compatible. First is that I'm not sure you can pull through https with a PHP stream (though not positive). Second is that there's nothing about that URL to indicate it's a file. ProcessWire isn't going to know what to do with it because there's no filename or extension. I think you'd have to find some other way to get this saved to a file and then import to ProcessWire from there. Link to comment Share on other sites More sharing options...
Adam Kiss Posted January 22, 2012 Author Share Posted January 22, 2012 Hey Ryan, you probably misunderstood I switched from generating the URL with '&' (HTML encoded ampersand) to '&' (ampersand only) and now it works. I pull the google image in, save the page, then do some renaming... and suddenly, I've got nicely named google charts Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now