Handle change in OpenPhoto API related to value of pathOriginal, closes #12

This commit is contained in:
Randy Hoyt 2012-01-28 12:22:48 -06:00
parent a5b090db2a
commit 9249f567ed
2 changed files with 16 additions and 11 deletions

View file

@ -3,7 +3,7 @@ Contributors: randyjensen,randyhoyt
Tags: openphoto,media Tags: openphoto,media
Requires at least: 3.2 Requires at least: 3.2
Tested up to: 3.3 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. 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 == == Changelog ==
= 0.9.X = = 0.9.4 =
* Including openphoto-php as a Git submodule * Including openphoto-php as a Git submodule
* Use title from OpenPhoto instead of filename * Use title from OpenPhoto instead of filename
* Handle change in OpenPhoto API related to value of pathOriginal
= 0.9.3 = = 0.9.3 =
* Force image sizes to be generated so image src will persist. * Force image sizes to be generated so image src will persist.

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
Plugin Name: OpenPhoto for WordPress Plugin Name: OpenPhoto for WordPress
Version: 0.9.3 Version: 0.9.4
Plugin URI: https://github.com/openphoto/openphoto-wordpress Plugin URI: https://github.com/openphoto/openphoto-wordpress
Author: Randy Hoyt, Randy Jensen Author: Randy Hoyt, Randy Jensen
Author URI: http://cultivatr.com/ Author URI: http://cultivatr.com/
@ -208,11 +208,15 @@ class WP_OpenPhoto {
$src["thumbnail"] = $photo->{"photo".$sizes['thumbnail']}[0]; $src["thumbnail"] = $photo->{"photo".$sizes['thumbnail']}[0];
$src["medium"] = $photo->{"photo".$sizes['medium']}[0]; $src["medium"] = $photo->{"photo".$sizes['medium']}[0];
$src["large"] = $photo->{"photo".$sizes['large']}[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 '<div id="media-item-'.$unique_id.'" class="media-item child-of-'.$post_id.' preloaded"><div class="progress" style="display: none; "></div><div id="media-upload-error-'.$unique_id.'"></div><div class="filename"></div>'; echo '<div id="media-item-'.$unique_id.'" class="media-item child-of-'.$post_id.' preloaded"><div class="progress" style="display: none; "></div><div id="media-upload-error-'.$unique_id.'"></div><div class="filename"></div>';
@ -227,12 +231,12 @@ class WP_OpenPhoto {
echo '<thead class="media-item-info" id="media-head-'.$unique_id.'">'; echo '<thead class="media-item-info" id="media-head-'.$unique_id.'">';
echo '<tr valign="top">'; echo '<tr valign="top">';
echo '<td class="A1B1" id="thumbnail-head-'.$unique_id.'">'; echo '<td class="A1B1" id="thumbnail-head-'.$unique_id.'">';
echo '<p style="height:100px;padding-right:10px;"><a href="http://'.$photo->appId.$photo->pathOriginal.'" target="_blank"><img class="thumbnail" src="'.$photo->path128x128.'" alt="" style="margin-top: 3px;"></a></p>'; echo '<p style="height:100px;padding-right:10px;"><a href="'.$src["original"].'" target="_blank"><img class="thumbnail" src="'.$photo->path128x128.'" alt="" style="margin-top: 3px;"></a></p>';
//echo '<p><input type="button" id="imgedit-open-btn-'.$unique_id.'" onclick="imageEdit.open( '.$unique_id.', &quot;98f2ea4727&quot; )" class="button" value="Edit Image"> <img src="'.home_url().'/wp-admin/images/wpspin_light.gif" class="imgedit-wait-spin" alt=""></p>'; //echo '<p><input type="button" id="imgedit-open-btn-'.$unique_id.'" onclick="imageEdit.open( '.$unique_id.', &quot;98f2ea4727&quot; )" class="button" value="Edit Image"> <img src="'.home_url().'/wp-admin/images/wpspin_light.gif" class="imgedit-wait-spin" alt=""></p>';
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td>';
echo '<p><strong>File name:</strong> '.substr(strrchr($photo->pathOriginal, "/"), 1 ).'</p>'; echo '<p><strong>File name:</strong> '.$src["original"].'</p>';
echo '<p><strong>File type:</strong> .'.substr(strrchr($photo->pathOriginal, "."), 1 ).'</p>'; echo '<p><strong>File type:</strong> .'.$src["original"].'</p>';
echo '<p><strong>Upload date:</strong> '.date('F d Y', (int) $photo->dateUploaded).'</p>'; echo '<p><strong>Upload date:</strong> '.date('F d Y', (int) $photo->dateUploaded).'</p>';
echo '<p><strong>Dimensions:</strong> <span id="media-dims-'.$unique_id.'">'.$photo->width.'&nbsp;×&nbsp;'.$photo->height.'</span> </p>'; echo '<p><strong>Dimensions:</strong> <span id="media-dims-'.$unique_id.'">'.$photo->width.'&nbsp;×&nbsp;'.$photo->height.'</span> </p>';
echo '</td>'; echo '</td>';
@ -311,7 +315,7 @@ class WP_OpenPhoto {
echo '<input type="radio" disabled="disabled" /><label for="image-size-large-'.$unique_id.'">Large</label>'; echo '<input type="radio" disabled="disabled" /><label for="image-size-large-'.$unique_id.'">Large</label>';
} }
echo '</div>'; echo '</div>';
echo '<div class="image-size-item"><input type="radio" name="attachments['.$unique_id.'][image-size]" id="image-size-full-'.$unique_id.'" value="full" alt="http://'.$photo->host.$photo->pathOriginal.'" data-image-height="'.$photo->height.'" data-image-width="'.$photo->width.'"' . $checked . '><label for="image-size-full-'.$unique_id.'">Full Size</label> <label for="image-size-full-'.$unique_id.'" class="help">('.$photo->width.'&nbsp;×&nbsp;'.$photo->height.')</label></div>'; echo '<div class="image-size-item"><input type="radio" name="attachments['.$unique_id.'][image-size]" id="image-size-full-'.$unique_id.'" value="full" alt="'.$src["original"].'" data-image-height="'.$photo->height.'" data-image-width="'.$photo->width.'"' . $checked . '><label for="image-size-full-'.$unique_id.'">Full Size</label> <label for="image-size-full-'.$unique_id.'" class="help">('.$photo->width.'&nbsp;×&nbsp;'.$photo->height.')</label></div>';
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '<tr class="submit">'; echo '<tr class="submit">';