a-ok Posted September 23, 2019 Share Posted September 23, 2019 Folks. Hope everyone is well. I'm attempting to move some Tumblr content to PW using the API. I have the below, which seems to work fine, except even though the images are uploaded (they appear in the appropriate assets/files/** folder), when I go to edit the page the images are all removed with the message Pageimages: Removed 'images' temp file(s) for page... Any thoughts where I'm going wrong? $url = $config->paths->templates . "tumblr/posts/posts.xml"; $xml = simplexml_load_file($url); $i = 0; foreach ($xml->posts->post as $post) { bdb($post); $attributes = $post->attributes(); $date = $sanitizer->date($attributes["unix-timestamp"]); $text = str_replace('</p>', '', $post->{"photo-caption"}); $text = explode('<p>', $text); $title = $sanitizer->text($text[2]); $description = array_slice($text, 3); $p = new Page(); $p->template = "blogSingle"; $p->parent = "/blog/"; $p->of(false); $p->title = $title; $p->date = $date; $descriptionString = ''; foreach ($description as $d) { $descriptionString .= "<p>" . $d . "</p>"; } $p->textarea = $descriptionString; $p->save(); if (count($post->photoset) > 0) { foreach ($post->{"photoset"}->{"photo"} as $images) { $image = $sanitizer->url($images->{"photo-url"}[0]); $p->images->add($image); $p->save(); } } else { $image = $sanitizer->url($post->{"photo-url"}[0]); $p->images->add($image); $p->save(); } $p->save(); $i++; if ($i == 2) break; } Link to comment Share on other sites More sharing options...
psy Posted September 23, 2019 Share Posted September 23, 2019 @a-ok try adding $p->of(false); before adding the image. You've included output formatting off above when creating the page, but then the page is saved which automatically turns it on again. 1 Link to comment Share on other sites More sharing options...
a-ok Posted September 23, 2019 Author Share Posted September 23, 2019 25 minutes ago, psy said: @a-ok try adding $p->of(false); before adding the image. You've included output formatting off above when creating the page, but then the page is saved which automatically turns it on again. @psy Many thanks for the help. It doesn't seem to make a difference unfortunately. Hmm... Link to comment Share on other sites More sharing options...
a-ok Posted September 24, 2019 Author Share Posted September 24, 2019 If I use TracyDebugger and run this: $page->of(false); $page->images->add("https://66.media.tumblr.com/f4958343844738fa507dc53d6493c988/tumblr_pszpc6YZF51uoauero1_1280.png"); $page->save(); It works fine ? 1 Link to comment Share on other sites More sharing options...
bernhard Posted September 24, 2019 Share Posted September 24, 2019 13 hours ago, a-ok said: $p->images->add($image); What happens if you replace this with the hardcoded url in the tracy example? Just replace block after block with working snippets and you'll find the problem or can at least narrow down where it is and tell us more about it ? Link to comment Share on other sites More sharing options...
a-ok Posted September 24, 2019 Author Share Posted September 24, 2019 1 hour ago, bernhard said: What happens if you replace this with the hardcoded url in the tracy example? Just replace block after block with working snippets and you'll find the problem or can at least narrow down where it is and tell us more about it ? Thanks, @bernhard – I did this and it added the images (visible in the folders within assets) but upon visiting it in the backend they were removed with the same message 'Pageimages: Removed 'images' temp file(s) for..' Link to comment Share on other sites More sharing options...
a-ok Posted September 24, 2019 Author Share Posted September 24, 2019 Okay. Bit of success! I had been using module 'ProcessCustomUploadNames' but when I disabled this it seemed to work fine and the images stayed! Any thoughts? Link to comment Share on other sites More sharing options...
a-ok Posted September 24, 2019 Author Share Posted September 24, 2019 I've decided to disable it, run the process, then re-enable it. As there is quite a lot of pages to create (200) with multiple images per page is there a best practice/method you would suggest in order to run this? Link to comment Share on other sites More sharing options...
bernhard Posted September 24, 2019 Share Posted September 24, 2019 1 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