From 9249f567ed2b2776792949679cfe9ac62e47fb24 Mon Sep 17 00:00:00 2001 From: Randy Hoyt Date: Sat, 28 Jan 2012 12:22:48 -0600 Subject: [PATCH] Handle change in OpenPhoto API related to value of pathOriginal, closes #12 --- README.txt | 5 +++-- openphoto-wordpress.php | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.txt b/README.txt index 6773fa3..43cb1c7 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ Contributors: randyjensen,randyhoyt Tags: openphoto,media Requires at least: 3.2 Tested up to: 3.3 -Stable tag: 0.9.3 +Stable tag: 0.9.4 Insert photos from your OpenPhoto installation into your WordPress content through the media manager. @@ -26,9 +26,10 @@ Find the project on [GitHub](https://github.com/openphoto/openphoto-wordpress "O == Changelog == -= 0.9.X = += 0.9.4 = * Including openphoto-php as a Git submodule * Use title from OpenPhoto instead of filename +* Handle change in OpenPhoto API related to value of pathOriginal = 0.9.3 = * Force image sizes to be generated so image src will persist. diff --git a/openphoto-wordpress.php b/openphoto-wordpress.php index d4623b8..be33dc0 100644 --- a/openphoto-wordpress.php +++ b/openphoto-wordpress.php @@ -1,7 +1,7 @@ {"photo".$sizes['thumbnail']}[0]; $src["medium"] = $photo->{"photo".$sizes['medium']}[0]; $src["large"] = $photo->{"photo".$sizes['large']}[0]; - $src["original"] = 'http://'.$photo->host.$photo->pathOriginal; + $src["original"] = $photo->pathOriginal; + if (strpos($src["original"],"http")===false) $src["original"] = 'http://'.$photo->host.$photo->pathOriginal; // in older versions of the API, pathOriginal did not have the full address - if ("" == $photo->title) { - $info = pathinfo($photo->pathOriginal); - $photo->title = basename($photo->pathOriginal,'.'.$info['extension']); + + + + if ("" == $photo->title) { + $info = pathinfo(basename($src["original"])); + $photo->title = basename($src["original"],'.'.$info['extension']); } echo '
'; @@ -227,12 +231,12 @@ class WP_OpenPhoto { echo ''; echo ''; echo ''; - echo '

'; + echo '

'; //echo '

'; echo ''; echo ''; - echo '

File name: '.substr(strrchr($photo->pathOriginal, "/"), 1 ).'

'; - echo '

File type: .'.substr(strrchr($photo->pathOriginal, "."), 1 ).'

'; + echo '

File name: '.$src["original"].'

'; + echo '

File type: .'.$src["original"].'

'; echo '

Upload date: '.date('F d Y', (int) $photo->dateUploaded).'

'; echo '

Dimensions: '.$photo->width.' × '.$photo->height.'

'; echo ''; @@ -311,7 +315,7 @@ class WP_OpenPhoto { echo ''; } echo '
'; - echo '
'; + echo '
'; echo ''; echo ''; echo '';