Jump to content

images uploaded via script not showing up in admin


anowitz
 Share

Recommended Posts

I've just started working on a custom script that will allow me to migrate images from my client's old site to my new PW site.  (The pages the images are going to be added to already exist on the new PW site.)

I am able to successfully add images using $page->images->add, but when I edit the page I've added the image to in admin, the image doesn't show up in my images field.

I'm relatively new to the API and assume I must be missing some basic piece here, maybe something have to do with Pageimage or OutputFormatting?

Any help is very much appreciated!

Here is the very preliminary code I'm using to test this out:

//these variables will eventually be arrays I'll iterate over...
$page_id = 'page id';
$description = 'image description';
$image_path = 'image url from old site';
//add image and image description
$page = wire("pages")->get($page_id);
$page->images->add('$image_path');
$page->images->last()->description = $description;
 
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

×
×
  • Create New...