示例#1
0
function getAttachedImages($dt, $lat, $lon, $dtoffset, &$error)
{
    $result = array();
    try {
        $attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => 'inherit', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ASC'));
        foreach ($attachments as $attachment_id => $attachment) {
            $img_src = wp_get_attachment_image_src($attachment_id, 'full');
            $img_thmb = wp_get_attachment_image_src($attachment_id, 'thumbnail');
            $img_metadata = wp_get_attachment_metadata($attachment_id);
            $item = array();
            $item["data"] = wp_get_attachment_link($attachment_id, array(105, 105));
            if (is_callable('exif_read_data')) {
                $exif = @exif_read_data($img_src[0]);
                if ($exif !== false) {
                    $item["lon"] = getExifGps($exif["GPSLongitude"], $exif['GPSLongitudeRef']);
                    $item["lat"] = getExifGps($exif["GPSLatitude"], $exif['GPSLatitudeRef']);
                    if ($item["lat"] != 0 || $item["lon"] != 0) {
                        $result[] = $item;
                    } else {
                        if (isset($p->imagedate)) {
                            $_dt = strtotime($p->imagedate) + $dtoffset;
                            $_item = findItemCoordinate($_dt, $dt, $lat, $lon);
                            if ($_item != null) {
                                $item["lat"] = $_item["lat"];
                                $item["lon"] = $_item["lon"];
                                $result[] = $item;
                            }
                        }
                    }
                }
            } else {
                $error .= "Sorry, <a href='http://php.net/manual/en/function.exif-read-data.php' target='_blank' >exif_read_data</a> function not found! check your hosting..<br />";
            }
        }
    } catch (Exception $e) {
        $error .= 'Error When Retrieving attached images: $e <br />';
    }
    return $result;
}
function getNGGalleryImages($ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset, &$error)
{
    $result = array();
    $galids = explode(',', $ngGalleries);
    $imgids = explode(',', $ngImages);
    if (!isNGGalleryActive()) {
        return '';
    }
    try {
        $pictures = array();
        foreach ($galids as $g) {
            $pictures = array_merge($pictures, nggdb::get_gallery($g));
        }
        foreach ($imgids as $i) {
            array_push($pictures, nggdb::find_image($i));
        }
        foreach ($pictures as $p) {
            $item = array();
            $item["data"] = $p->thumbHTML;
            if (is_callable('exif_read_data')) {
                $exif = @exif_read_data($p->imagePath);
                if ($exif !== false) {
                    $item["lon"] = getExifGps($exif["GPSLongitude"], $exif['GPSLongitudeRef']);
                    $item["lat"] = getExifGps($exif["GPSLatitude"], $exif['GPSLatitudeRef']);
                    if ($item["lat"] != 0 || $item["lon"] != 0) {
                        $result[] = $item;
                    } else {
                        if (isset($p->imagedate)) {
                            $_dt = strtotime($p->imagedate) + $dtoffset;
                            $_item = findItemCoordinate($_dt, $dt, $lat, $lon);
                            if ($_item != null) {
                                $item["lat"] = $_item["lat"];
                                $item["lon"] = $_item["lon"];
                                $result[] = $item;
                            }
                        }
                    }
                }
            } else {
                $error .= "Sorry, <a href='http://php.net/manual/en/function.exif-read-data.php' target='_blank' >exif_read_data</a> function not found! check your hosting..<br />";
            }
        }
        /* START FIX NEXT GEN GALLERY 2.x */
        if (class_exists("C_Component_Registry")) {
            $renderer = C_Component_Registry::get_instance()->get_utility('I_Displayed_Gallery_Renderer');
            $params['gallery_ids'] = $ngGalleries;
            $params['image_ids'] = $ngImages;
            $params['display_type'] = NEXTGEN_GALLERY_BASIC_THUMBNAILS;
            $params['images_per_page'] = 999;
            // also add js references to get the gallery working
            $dummy = $renderer->display_images($params, $inner_content);
            /* START FIX NEXT GEN GALLERY PRO */
            if (preg_match("/data-nplmodal-gallery-id=[\"'](.*?)[\"']/", $dummy, $m)) {
                $galid = $m[1];
                if ($galid) {
                    for ($i = 0; $i < count($result); ++$i) {
                        $result[$i]["data"] = str_replace("%PRO_LIGHTBOX_GALLERY_ID%", $galid, $result[$i]["data"]);
                    }
                }
            }
            /* END FIX NEXT GEN GALLERY PRO */
        }
        /* END FIX NEXT GEN GALLERY 2.x */
    } catch (Exception $e) {
        $error .= 'Error When Retrieving NextGen Gallery galleries/images: $e <br />';
    }
    return $result;
}