Пример #1
0
 /**
  * 图片裁剪
  *
  */
 public function pic_cutOp()
 {
     import('function.thumb');
     if (chksubmit()) {
         $thumb_width = $_POST['x'];
         $x1 = $_POST["x1"];
         $y1 = $_POST["y1"];
         $x2 = $_POST["x2"];
         $y2 = $_POST["y2"];
         $w = $_POST["w"];
         $h = $_POST["h"];
         $scale = $thumb_width / $w;
         $src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']);
         $save_file2 = str_replace('_small.', '_sm.', $src);
         $cropped = resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale);
         @unlink($src);
         $pathinfo = pathinfo($save_file2);
         exit($pathinfo['basename']);
     } else {
         Language::read('cut');
         $lang = Language::getLangContent();
     }
     $save_file = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_GET['url']);
     $_GET['x'] = intval($_GET['x']) > 50 && $_GET['x'] < 400 ? $_GET['x'] : 200;
     $_GET['y'] = intval($_GET['y']) > 50 && $_GET['y'] < 400 ? $_GET['y'] : 200;
     $_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1';
     Tpl::output('height', get_height($save_file));
     Tpl::output('width', get_width($save_file));
     Tpl::showpage('cut', 'null_layout');
 }
Пример #2
0
 /**
  * 图片裁剪
  *
  */
 public function pic_cutOp()
 {
     Language::read('admin_common');
     $lang = Language::getLangContent();
     import('function.thumb');
     if (chksubmit()) {
         $thumb_width = $_POST['x'];
         $x1 = $_POST["x1"];
         $y1 = $_POST["y1"];
         $x2 = $_POST["x2"];
         $y2 = $_POST["y2"];
         $w = $_POST["w"];
         $h = $_POST["h"];
         $scale = $thumb_width / $w;
         $src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']);
         if (strpos($src, '..') !== false || strpos($src, BASE_UPLOAD_PATH) !== 0) {
             exit;
         }
         if (!empty($_POST['filename'])) {
             // 				$save_file2 = BASE_UPLOAD_PATH.'/'.$_POST['filename'];
             $save_file2 = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['filename']);
         } else {
             $save_file2 = str_replace('_small.', '_sm.', $src);
         }
         $cropped = resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale);
         @unlink($src);
         $pathinfo = pathinfo($save_file2);
         exit($pathinfo['basename']);
     }
     $save_file = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_GET['url']);
     $_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1';
     Tpl::output('height', get_height($save_file));
     Tpl::output('width', get_width($save_file));
     Tpl::showpage('common.pic_cut', 'null_layout');
 }
Пример #3
0
 public function uploadOp()
 {
     if (!chksubmit()) {
         redirect('index.php?act=home&op=avatar');
     }
     import('function.thumb');
     Language::read('member_home_member,cut');
     $lang = Language::getLangContent();
     $member_id = $_SESSION['member_id'];
     //上传图片
     $upload = new UploadFile();
     $upload->set('thumb_width', 500);
     $upload->set('thumb_height', 499);
     $ext = strtolower(pathinfo($_FILES['pic']['name'], PATHINFO_EXTENSION));
     $upload->set('file_name', "avatar_{$member_id}.{$ext}");
     $upload->set('thumb_ext', '_new');
     $upload->set('ifremove', true);
     $upload->set('default_dir', ATTACH_AVATAR);
     if (!empty($_FILES['pic']['tmp_name'])) {
         $result = $upload->upfile('pic');
         if (!$result) {
             showMessage($upload->error, '', 'html', 'error');
         }
     } else {
         showMessage('upload failed', '', 'html', 'error');
     }
     self::profile_menu('member', 'avatar');
     Tpl::output('menu_sign', 'profile');
     Tpl::output('menu_sign_url', 'index.php?act=member&op=home');
     Tpl::output('menu_sign1', 'avatar');
     Tpl::output('newfile', $upload->thumb_image);
     Tpl::output('height', get_height(BASE_UPLOAD_PATH . '/' . ATTACH_AVATAR . '/' . $upload->thumb_image));
     Tpl::output('width', get_width(BASE_UPLOAD_PATH . '/' . ATTACH_AVATAR . '/' . $upload->thumb_image));
     Tpl::setLayout('member_pub_layout');
     Tpl::showpage('member_profile.avatar');
 }
Пример #4
0
 /**
  * POST 上传头像图片
  */
 public function uploadOp()
 {
     if (!isset($_POST)) {
         output_error("请求方式错误");
         die;
     }
     import('function.thumb');
     $member_id = $this->member_id;
     //上传图片
     $upload = new UploadFile();
     $upload->set('thumb_width', 500);
     $upload->set('thumb_height', 499);
     $ext = strtolower(pathinfo($_FILES['pic']['name'], PATHINFO_EXTENSION));
     $upload->set('file_name', "avatar_{$member_id}.{$ext}");
     $upload->set('thumb_ext', '_new');
     $upload->set('ifremove', true);
     $upload->set('default_dir', ATTACH_AVATAR);
     if (!empty($_FILES['pic']['tmp_name'])) {
         $result = $upload->upfile('pic');
         if (!$result) {
             output_error("上传失败");
             die;
         }
     } else {
         output_error('上传失败,请尝试更换图片格式或小图片');
         die;
     }
     $thumb_img = array('newfile' => $upload->thumb_image, 'height' => get_height(BASE_UPLOAD_PATH . '/' . ATTACH_AVATAR . '/' . $upload->thumb_image), 'width' => get_width(BASE_UPLOAD_PATH . '/' . ATTACH_AVATAR . '/' . $upload->thumb_image));
     output_data(array('avatar' => $upload->thumb_image));
 }
Пример #5
0
 /**
  * 上传头像
  */
 public function uploadOp()
 {
     if (!chksubmit()) {
         redirect('index.php?act=storesetting&op=avatar');
     }
     import('function.thumb');
     $store_id = $_SESSION['store_id'];
     //上传图片
     if (!empty($_FILES['uploadimg']['name'])) {
         $upload = new UploadFile();
         $uploaddir = ATTACH_MEMBER_PATH;
         $upload->set('thumb_width', 500);
         $upload->set('thumb_height', 499);
         $ext = strtolower(pathinfo($_FILES['uploadimg']['name'], PATHINFO_EXTENSION));
         $upload->set('file_name', "tmp_store_avatar_{$store_id}.{$ext}");
         $upload->set('thumb_ext', '_new');
         $upload->set('ifremove', true);
         $upload->set('default_dir', $uploaddir);
         $result = $upload->upfile('uploadimg');
         if ($result) {
             Tpl::output('newfile', $upload->thumb_image);
             Tpl::output('height', get_height(BASE_UPLOAD_PATH . '/shop/member/' . $upload->thumb_image));
             Tpl::output('width', get_width(BASE_UPLOAD_PATH . '/shop/member/' . $upload->thumb_image));
             Tpl::showpage('store.avatar');
         } else {
             $this->showTip('图片文件上传失败', '', 'html', 'error');
         }
     } else {
         $this->showTip('请选择要上传的头像图片文件', '', 'html', 'error');
     }
 }
    function setup_elements(&$mform)
    {
        global $CFG, $RESOURCE_WINDOW_OPTIONS;
        if (KalturaHelpers::getPlatformKey("partner_id", "none") == "none") {
            //        $basic = get_string('needreg', 'kaltura');
            //        $str = str_replace("##SERVER##", $CFG->wwwroot . "/admin/settings.php?section=modsettingkaltura", $basic);
            //        $mform->addElement('static', 'pleasereg',$str, '');
            redirect($CFG->wwwroot . "/admin/module.php?module=kaltura");
            die;
            //        return;
        }
        if (isset($_GET['update'])) {
            $item_id = $_GET['update'];
            $result = get_record('course_modules', 'id', $item_id);
            $result = get_record('resource', 'id', $result->instance);
            $entry = get_record('kaltura_entries', 'context', "R_" . "{$result->id}");
            $default_entry = $entry;
        } else {
            $last_entry_id = get_field('kaltura_entries', 'max(id)', 'id', 'id');
            if (!empty($last_entry_id)) {
                $default_entry = get_record('kaltura_entries', 'id', "{$last_entry_id}");
                $default_entry->title = "";
            } else {
                $default_entry = new kaltura_entry();
            }
        }
        $hidden_alltext = new HTML_QuickForm_hidden('alltext', $default_entry->dimensions, array('id' => 'id_alltext'));
        $mform->addElement($hidden_alltext);
        $hidden_popup = new HTML_QuickForm_hidden('popup', '', array('id' => 'id_popup'));
        $mform->addElement($hidden_popup);
        $hidden_dimensions = new HTML_QuickForm_hidden('dimensions', $default_entry->dimensions, array('id' => 'id_dimensions'));
        $mform->addElement($hidden_dimensions);
        $hidden_size = new HTML_QuickForm_hidden('size', $default_entry->size, array('id' => 'id_size'));
        $mform->addElement($hidden_size);
        $hidden_custom_width = new HTML_QuickForm_hidden('custom_width', $default_entry->custom_width, array('id' => 'id_custom_width'));
        $mform->addElement($hidden_custom_width);
        $hidden_design = new HTML_QuickForm_hidden('design', $default_entry->design, array('id' => 'id_design'));
        $mform->addElement($hidden_design);
        $hidden_title = new HTML_QuickForm_hidden('title', $default_entry->title, array('id' => 'id_title'));
        $mform->addElement($hidden_title);
        $hidden_entry_type = new HTML_QuickForm_hidden('entry_type', $default_entry->entry_type, array('id' => 'id_entry_type'));
        $mform->addElement($hidden_entry_type);
        $text_video = new HTML_QuickForm_static('video_text', null, '<span id="spanExplain"><table style="width:100%;font-size:9px;"><tr><td width="25%">' . get_string('videotext', 'resource_kalturavideo') . '</td><td style="width:40%;padding-left:25px;">' . get_string('videoremixtext', 'resource_kalturavideo') . '</td><td width="35%">&nbsp;</td></tr></table></span>');
        //   $text_video_remix = new HTML_QuickForm_static('video_text_remix',null, 'bbb');
        $button = new HTML_QuickForm_input();
        $button->setName('addvid');
        $button->setType('button');
        $button->setValue('Add Video');
        $button_editable = new HTML_QuickForm_input();
        $button_editable->setName('addeditvid');
        $button_editable->setType('button');
        $button_editable->setValue('Add Editable Video');
        $button_replace = new HTML_QuickForm_input();
        $button_replace->setName('replacevid');
        $button_replace->setType('button');
        $button_replace->setValue('Replace Video');
        $button_preview = new HTML_QuickForm_input();
        $button_preview->setName('previewvid');
        $button_preview->setType('button');
        $button_preview->setValue('Preview Video');
        $button_preview_edit = new HTML_QuickForm_input();
        $button_preview_edit->setName('previeweditvid');
        $button_preview_edit->setType('button');
        $button_preview_edit->setValue('Preview & Edit Video');
        $videolabel = get_string('addvideo', 'resource_kalturavideo');
        $videoeditablelabel = get_string('editablevideo', 'resource_kalturavideo');
        $replacelabel = get_string('replacevideo', 'resource_kalturavideo');
        $previewlabel = get_string('previewvideo', 'resource_kalturavideo');
        $previeweditlabel = get_string('previeweditvideo', 'resource_kalturavideo');
        $cw_url = $CFG->wwwroot . '/mod/kaltura/kcw.php?';
        $cw_url_init = $cw_url;
        $edit_url = $CFG->wwwroot . '/mod/kaltura/keditor.php?';
        $edit_url_init = $edit_url;
        $preview_url = $CFG->wwwroot . '/mod/kaltura/kpreview.php?';
        $preview_url_init = $preview_url;
        if (!empty($entry)) {
            $cw_url_init .= 'id=' . $entry->id;
            $preview_url_init .= 'entry_id=' . $entry->entry_id . '&design=' . $entry->design . '&width=' . get_width($entry) . '&dimensions=' . $entry->dimensions;
            $edit_url_init .= 'entry_id=' . $entry->entry_id;
        }
        $button_attributes = array('type' => 'button', 'onclick' => 'set_entry_type(' . KalturaEntryType::MEDIA_CLIP . ');kalturaInitModalBox(\'' . $cw_url_init . '&upload_type=video' . '\', {width:760, height:422});', 'id' => 'id_addvideo', 'value' => $videolabel, 'style' => empty($entry) ? 'display:inline' : 'display:none');
        $button_attributes_editable = array('type' => 'button', 'onclick' => 'set_entry_type(' . KalturaEntryType::MIX . ');kalturaInitModalBox(\'' . $cw_url_init . '&upload_type=mix' . '\', {width:760, height:422});', 'id' => 'id_addeditablevideo', 'value' => $videoeditablelabel, 'style' => empty($entry) ? 'display:inline;margin-left:90px;' : 'display:none');
        $button_attributes_replace = array('type' => 'button', 'onclick' => 'kalturaInitModalBox(\'' . $cw_url_init . (empty($entry) ? '' : ($entry->entry_type == KalturaEntryType::MEDIA_CLIP ? '&upload_type=video' : '&upload_type=mix')) . '\', {width:760, height:422});', 'id' => 'id_replace', 'value' => $replacelabel, 'style' => empty($entry) ? 'display:none' : 'display:inline');
        $button_attributes_preview = array('type' => 'button', 'onclick' => 'kalturaInitModalBox(\'' . $preview_url_init . '\', ' . (empty($entry) ? '{width:400, height:382}' : '{width:' . get_width($entry) . ', height:' . (get_height($entry) + 50) . '}') . ');', 'id' => 'id_preview', 'value' => $previewlabel, 'style' => empty($entry) || $entry->entry_type != KalturaEntryType::MEDIA_CLIP ? 'display:none' : 'display:inline');
        $button_attributes_preview_edit = array('type' => 'button', 'onclick' => 'kalturaInitModalBox(\'' . $edit_url_init . '\', {width:890, height:546});', 'id' => 'id_preview_edit', 'value' => $previeweditlabel, 'style' => empty($entry) || $entry->entry_type != KalturaEntryType::MIX ? 'display:none' : 'display:inline');
        $resource = $this->resource;
        $thumbnail = "";
        if (isset($_GET['update'])) {
            if (!empty($entry)) {
                $thumbnail = '<img id="id_thumb" src="' . KalturaHelpers::getThumbnailUrl(null, $entry->entry_id, 140, 105) . '" />';
                //	    $mform->addElement('static', 'video_thumb', get_string('video', 'resource_kalturavideo'), $thumbnail);
            }
        }
        $button->setAttributes($button_attributes);
        $button_editable->setAttributes($button_attributes_editable);
        $button_replace->setAttributes($button_attributes_replace);
        $button_preview->setAttributes($button_attributes_preview);
        $button_preview_edit->setAttributes($button_attributes_preview_edit);
        $objs = array();
        $objs[] =& $button;
        $objs[] =& $button_editable;
        $objs[] =& $button_replace;
        $objs[] =& $button_preview;
        $objs[] =& $button_preview_edit;
        $text_objs = array();
        $text_objs[] = $text_video;
        $divWait = '<div style="border:1px solid #bcbab4;background-color:#f5f1e9;width:140px;height:105px;float:left;text-align:center;;font-size:85%;display:' . (empty($thumbnail) ? 'none' : 'inline') . '" id="divWait">' . $thumbnail . '</div>
  <script type="text/javascript">
   function set_entry_type(type)
   {
      document.getElementById("id_entry_type").value = type;
   }
  
   function get_height()
   {
      if (get_field("id_dimensions") == "' . KalturaAspectRatioType::ASPECT_4_3 . '")
      {
        switch(get_field("id_size"))
        {
          case "' . KalturaPlayerSize::LARGE . '":
            return 445;
            break;
          case "' . KalturaPlayerSize::SMALL . '":
            return 340;
            break;
          case "' . KalturaPlayerSize::CUSTOM . '":
            return parseInt(get_field("id_custom_width"))*3/4 + 65 + 80;
            break;
          default:
            return 445;
           break;
        }
      }
      else
      {
        switch(get_field("id_size"))
        {
          case "' . KalturaPlayerSize::LARGE . '":
            return 370;
           break;
          case "' . KalturaPlayerSize::SMALL . '":
            return 291;
            break;
          case "' . KalturaPlayerSize::CUSTOM . '":
            return parseInt(get_field("id_custom_width"))*9/16 + 65 + 80;
            break;
          default:
            return 370;
            break;
        }
      
      }
   
   }
  
   function get_width()
   {
    switch(get_field("id_size"))
    {
      case "' . KalturaPlayerSize::LARGE . '":
        return 450;
        break;
      case "' . KalturaPlayerSize::SMALL . '":
        return 310;
        break;
      case "' . KalturaPlayerSize::CUSTOM . '":
        return parseInt(get_field("id_custom_width")) + 50;
        break;
      default:
        return 450;
        break;
    }   
   }
      
   function do_on_wait()
   {
      var entryId = document.getElementById("id_alltext").value;
      document.getElementById("id_addvideo").style.display="none";
      document.getElementById("id_addeditablevideo").style.display="none";
      document.getElementById("id_replace").style.display="inline";
      if (document.getElementById("spanExplain") != null)
      {
        document.getElementById("spanExplain").style.display = "none";
      }
      
      if (document.getElementById("id_entry_type").value == ' . KalturaEntryType::MEDIA_CLIP . ')
      {
        var design = get_field("id_design");
        var width = get_width();
        var dimensions = get_field("id_dimensions");
        document.getElementById("id_preview").style.display="inline";
//        document.getElementById("id_preview").onclick=new Function("kalturaInitModalBox(\'' . $preview_url . 'entry_id=" + entryId + "\', {width:400, height:382})");
        document.getElementById("id_preview").onclick=new Function("kalturaInitModalBox(\'' . $preview_url . 'entry_id=" + entryId + "&design=" + design + "&width=" + width + "&dimensions=" + dimensions + "\', {width:get_width(), height:get_height()})"); //width:get_width()+10
     }
      else
      {
        document.getElementById("id_preview_edit").style.display="inline";
        document.getElementById("id_preview_edit").onclick=new Function("kalturaInitModalBox(\'' . $edit_url . 'entry_id=" + entryId + "\', {width:890, height:546})");
        document.getElementById("id_replace").onclick=new Function("kalturaInitModalBox(\'' . $cw_url . '&upload_type=mix\', {width:760, height:422})");
      }
   }
   </script>';
        $mform->addElement('static', 'divWait', '', get_wait_image("divWait", "id_alltext"));
        $mform->addElement('static', 'please_wait', empty($entry) ? '' : get_string('video', 'resource_kalturavideo'), $divWait);
        $mform->addElement('group', 'videogroup', empty($entry) ? get_string('video', 'resource_kalturavideo') : '', $objs);
        if (!isset($_GET['update'])) {
            $mform->addElement('group', 'videotextgroup', '', $text_objs);
        }
        $mform->addElement('header', 'displaysettings', get_string('display', 'resource'));
        return;
    }
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
$meta = '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/kaltura/styles.php" />' . "\n";
//$meta = '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/mod/kaltura/css/kaltura.css" />'."\n";
print_header('Kaltura Preview', '', '', '', $meta);
$id = '';
if (isset($_GET['entry_id'])) {
    $id = $_GET['entry_id'];
}
if (empty($id)) {
    die('missing id');
}
if (isset($_GET['design'])) {
    $design = $_GET['design'];
} else {
    $design = 'light';
}
$entry = new kaltura_entry();
if (isset($_GET['width']) && isset($_GET['dimensions'])) {
    $entry->dimensions = $_GET['dimensions'];
    $entry->custom_width = $_GET['width'];
    $entry->size = KalturaPlayerSize::CUSTOM;
} else {
    $entry->dimensions = KalturaPlayerSize::LARGE;
    $entry->custom_width = 400;
    $entry->size = KalturaPlayerSize::CUSTOM;
}
echo embed_kaltura($id, get_width($entry), get_height($entry), KalturaEntryType::MEDIA_CLIP, $design);
echo '<div style="width:400px; margin-top:15px; text-align:center;"><input type="button"  value="' . get_string("close", "kaltura") . '" onclick="window.parent.kalturaCloseModalBox();" />';
print_footer();
Пример #8
-1
function get_photos($post_id, $num = 0, $sizes = null, $ret = null, $landscape = null)
{
    // save the image with the highest priority
    // to use when returing only one image
    $top_priority['priority'] = 9999;
    // check if there are attachments
    if ($images = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'order' => 'ASC', 'orderby' => 'menu_order', 'post_mime_type' => 'image'))) {
        // loop through each image
        foreach ($images as $image) {
            $image->attachment_metadata = wp_get_attachment_metadata($image->ID);
            if (isset($photo['photos'])) {
                $i = count($photo['photos']);
            } else {
                $i = 0;
            }
            // store image information
            $photo['photos'][$i]['id'] = get_id($image);
            $photo['photos'][$i]['caption'] = get_caption($image);
            $photo['photos'][$i]['credit'] = get_credit($image);
            $photo['photos'][$i]['priority'] = get_priority($image);
            $photo['photos'][$i]['width'] = get_width($image);
            $photo['photos'][$i]['height'] = get_height($image);
            // return requested sizes
            if ($sizes) {
                foreach ($sizes as $size) {
                    $photo['photos'][$i]['src'][$size] = get_src($image, $size);
                }
            } else {
                // return all sizes when none are specified
                $photo['photos'][$i]['src']['full'] = get_src($image, 'full');
                $photo['photos'][$i]['src']['large'] = get_src($image, 'large');
                $photo['photos'][$i]['src']['thumbnail'] = get_src($image, 'thumbnail');
                $photo['photos'][$i]['src']['medium'] = get_src($image, 'medium');
                $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline');
                $photo['photos'][$i]['src']['alt-thumbnail'] = get_src($image, 'alt-thumbnail');
                $photo['photos'][$i]['src']['custom-495'] = get_src($image, 'custom-495');
                $photo['photos'][$i]['src']['custom-165'] = get_src($image, 'custom-165');
                $photo['photos'][$i]['src']['custom-260'] = get_src($image, 'custom-260');
                $photo['photos'][$i]['src']['custom-75x75-crop'] = get_src($image, 'custom-75x75-crop');
            }
            // store the photo with the highest priority in wordpress.
            // photos with high priorities are given low numbers.
            // photos with priority of -1 are ignored.
            if ($num === 1 && $photo['photos'][$i]['priority'] < $top_priority['priority'] && $photo['photos'][$i]['priority'] >= 0) {
                // if user wants a landscape photo, check
                // to make sure it is landscape
                if ($landscape && !is_landscape($image)) {
                    continue;
                }
                $top_priority = $photo['photos'][$i];
            }
            // determine image position based on priority
            if (!isset($photo['display']['feature']) && get_priority($image) === 1) {
                // feature photo - below headline
                $photo['display']['feature'] = $i;
                $photo['photos'][$i]['src']['single-feature'] = get_src($image, 'single-feature');
            } elseif (!isset($photo['display']['inline']) && get_priority($image) === 2) {
                // inline photo - thumbnail w/in post
                $photo['display']['inline'] = $i;
                $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline');
            } else {
                if (!isset($photo['display']['inline'])) {
                    // inline photo has not been set
                    $photo['display']['inline'] = $i;
                    $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline');
                } else {
                    // gallery photo - appears in post photo gallery
                    if (isset($photo['display']['gallery'])) {
                        $photo['display']['gallery'][count($photo['display']['gallery'])] = $i;
                    } else {
                        $photo['display']['gallery'][0] = $i;
                    }
                }
            }
            // return first photo when one is requested and there is only one
            if ($num === 1 && count($images) == 1) {
                return $photo['photos'][$i];
            }
        }
        // returns top photo when one is requested.
        // if user only wants one landscape photo,
        // but the top_priority is not landscape, don't
        // return anything.
        if ($num === 1) {
            if ($landscape && !is_landscape($image)) {
                return false;
            }
            return $top_priority;
        }
        // return all of the requested photos
        return $photo;
    } else {
        // check if the image is from the archives. images on our old
        // websites (custom CMS for some time then College Publisher)
        // were not saved as attachments, but were stored as custom
        // fields.
        $meta = get_post_custom($post_id);
        if ($meta && isset($meta['_image1'])) {
            $meta['_image1'] = get_image($meta['_image1']);
            // needed to make legacy photo output look like current photos
            $photo['photos'][0] = $meta['_image1'];
            $photo['photos'][0]['priority'] = 0;
            $photo['display']['inline'] = 0;
            if ($num === 1) {
                return $photo['photos'][0];
            }
            return $photo;
        }
    }
    // no images were found
    return false;
}