Jump to content

Generate thumbnail from api?


nghi
 Share

Recommended Posts

the follow code works and downloads the image from the url. However, it doesn't generate the thumb nail in the back end. 

EG.

$page = new page();
$page->template = 'basic';
$page->tittle = 'testing';
$page->save;
$page->image = http://i.imgur.com/nFJzvUQ.jpg;
$page->save;

nFJzvUQ.200.00.jpg would not exist

nFJzvUQ.jpg exist

How do i genereate the thumbnail so it doesn't appear broken in the backend.

 

Link to comment
Share on other sites

There are a few small things wrong with that code - missing parent, save not save() etc.

This works for me:

$p = new page();
$p->template = 'basic-page';
$p->parent = $pages->get(1); //set parent to homepage
$p->title = 'testing7';
$p->save();
$p->images->add("http://i.imgur.com/nFJzvUQ.jpg");
$p->save();

Are you talking about the  thumb that gets created when you have "Display Thumbnails in Page Editor" checked. The 200 in the filename is throwing me, since these are usually 100px high.

I am getting the thumbnail created as soon as I load the page in the admin. What version of PW are you running?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...