From 7de1dabd5ccb843a37fd19dd138b24f4a00806a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Andr=C3=A8=20Str=C3=B8mland?= Date: Fri, 11 Jan 2019 14:50:18 +0100 Subject: [PATCH] . --- devices/DOSDrivers/Wordpress/door.php | 51 ++++++++++++++++++++------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/devices/DOSDrivers/Wordpress/door.php b/devices/DOSDrivers/Wordpress/door.php index ab216cdabc..422f1ec18e 100644 --- a/devices/DOSDrivers/Wordpress/door.php +++ b/devices/DOSDrivers/Wordpress/door.php @@ -1657,7 +1657,7 @@ function dosAction( $args ) $obj->{$mapping[$k]} = $o; } - else if( $k == 'Image' && $data != '' && strstr( $data, 'http' ) ) + else if( $k == 'Image' && $data != '' && ( strstr( $data, 'http' ) || strstr( substr( trim( $data ), 0, 2 ), '\\' ) ) ) { if( $this->CurlUrlExists( trim( $data ), 'content_type=>image' ) ) { @@ -1748,11 +1748,18 @@ function dosAction( $args ) $obj->categories = json_decode( '[{"id": "'.$file->parent.'"}]' ); // If image missing set parent image if defined ... - - if( !$obj->images && $file->image ) - { - $obj->images = $file->image; - } + + if( !$obj->images && $file->parentimage ) + { + if( isset( $file->parentimage->src ) ) + { + $obj->images = $file->parentimage->src; + } + else + { + $obj->images = $file->parentimage; + } + } //$Logger->log( '[[[[[[[[[[ Uploading ]]]]]]]]]] ' . print_r( $dta,1 ) . ' [] ' . print_r( $obj,1 ) ); @@ -2684,7 +2691,7 @@ private function CreateCategoryWP( $cat, $dta = false, $log = false ) $obj->{$mapping[$k]} = $o; } - else if( $k == 'Image' && $data != '' && strstr( $data, 'http' ) ) + else if( $k == 'Image' && $data != '' && ( strstr( $data, 'http' ) || strstr( substr( trim( $data ), 0, 2 ), '\\' ) ) ) { if( $this->CurlUrlExists( trim( $data ), 'content_type=>image' ) ) { @@ -2723,10 +2730,17 @@ private function CreateCategoryWP( $cat, $dta = false, $log = false ) // If image missing set parent image if defined ... - if( !$obj->image && $cat->image ) - { - $obj->image = $cat->image; - } + if( !$obj->image && $cat->parentimage ) + { + if( isset( $cat->parentimage->src ) ) + { + $obj->image = $cat->parentimage->src; + } + else + { + $obj->image = $cat->parentimage; + } + } if( isset( $obj->image ) ) { @@ -3134,7 +3148,7 @@ function putFile( $path, $fileObject ) $obj->{$mapping[$k]} = $o; } - else if( $k == 'Image' && $data != '' && strstr( $data, 'http' ) ) + else if( $k == 'Image' && $data != '' && ( strstr( $data, 'http' ) || strstr( substr( trim( $data ), 0, 2 ), '\\' ) ) ) { if( $this->CurlUrlExists( trim( $data ), 'content_type=>image' ) ) { @@ -3203,6 +3217,19 @@ function putFile( $path, $fileObject ) $obj->categories = json_decode( '[{"id": "'.$file->parent.'"}]' ); + // If image missing set parent image if defined ... + + if( !$obj->images && $file->parentimage ) + { + if( isset( $file->parentimage->src ) ) + { + $obj->images = $file->parentimage->src; + } + else + { + $obj->images = $file->parentimage; + } + } // TODO: temporary that it deletes and creates new images every prod update, perhaps work with ID here also instead of filename