示例#1
0
function easy_media_gnl_shortcode($attsn)
{
    if (easy_get_option('easymedia_disen_plug') == '1') {
        extract(shortcode_atts(array('med' => -1, 'size' => ''), $attsn));
        ob_start();
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        // for pagination
        $deff_img_limit = easy_get_option('easymedia_img_size_limit');
        // get the default image size limit
        $theopt = easy_get_option('easymedia_frm_size');
        $imwidth = stripslashes($theopt['width']);
        $imheight = stripslashes($theopt['height']);
        if ($med > '0') {
            $finid = explode(",", $med);
            $medinarr = $finid;
            $emargs = emg_gallery_gen($finid, $paged);
        }
        $emg_query = new WP_Query($emargs);
        if ($emg_query->have_posts()) {
            $mediauniqueid = emgRandomString(6);
            //Random class for fitText
            echo '<div class="pagwrap"><div class="easycontainer emgclearfix">';
            echo '<div class="rig">';
            while ($emg_query->have_posts()) {
                $emg_query->the_post();
                $images = get_post_meta(get_the_id(), 'easmedia_metabox_media_gallery', true);
                $isresize = get_post_meta(get_the_id(), 'easmedia_metabox_media_gallery_opt1', true);
                if (is_array($images)) {
                    $ig = 0;
                    foreach ($images as $img_id) {
                        $img = wp_get_attachment_image_src($img_id, 'full');
                        $img_url = easymedia_imgresize($img[0], $deff_img_limit, $isresize, $img[1], $img[2]);
                        $img_url = explode(",", $img_url);
                        $img_info = get_post($img_id);
                        $ext = pathinfo($img[0], PATHINFO_EXTENSION);
                        $filenm = basename($img[0], "." . $ext);
                        $emgthumbimg = easymedia_resizer($img[0], $img[1], $img[2], $imwidth, $imheight, true);
                        if (get_post_meta(get_the_id(), 'easmedia_metabox_media_gallery_opt2', true) == 'on') {
                            $thumbttl = $img_info->post_title;
                            $thumbttl = esc_html(esc_js($thumbttl));
                        } else {
                            $thumbttl = get_post_meta(get_the_id(), 'easmedia_metabox_title', true);
                        }
                        emg_gallery_markup($imwidth, $imheight, get_the_id() . '-' . $img_id, $img_url[0], $emgthumbimg, $filenm, stripslashes($thumbttl));
                    }
                } else {
                    echo '<div style="display:none"></div>';
                }
                ?>

<?php 
            }
        } else {
            echo '<div class="easymedia_center">';
            echo '<div class="view"><img src="' . plugins_url('images/ajax-loader.gif', __FILE__) . '" width="32" height="32"/></div>';
            $contnt = ob_get_clean();
            return $contnt;
        }
        wp_reset_postdata();
        echo '<div style="clear:both;"></div>';
        echo '</div></div>';
        // @since 1.3.75
        if (emg_get_aff_option('emg_affiliate_info', 'emg_aff_id', '')) {
            echo '<span class="emg-aff-link">Powered by <a href="https://secure.ghozylab.com/demo/?ref=' . emg_get_aff_option('emg_affiliate_info', 'emg_aff_id', '') . '&goto=emg" target="_blank">Easy Media Gallery Plugin</a></span>';
        }
        echo '</div>';
        // JS
        emg_put_script();
        // Dinamic CSS
        echo '<style>/*Dynamic CSS - By GhozyLab*/';
        echo emg_dynamic_css_generator();
        echo '</style>';
        $content = ob_get_clean();
        return $content;
    } else {
        ob_start();
        echo '<div style="display: none;"></div>';
        $contnt = ob_get_clean();
        return $contnt;
    }
}
示例#2
0
function easymedia_imgresize_ajax()
{
    check_ajax_referer('easymedia-thumb', 'security');
    if (!isset($_POST['imgurl']) || !isset($_POST['limiter']) || $_POST['imgurl'] == '' || $_POST['limiter'] == '') {
        echo '<p>Ajax request failed, please refresh your browser window.</p>';
        wp_die();
    } else {
        $imgurl = $_POST['imgurl'];
        $limiter = $_POST['limiter'];
        $attid = wp_get_attachment_image_src(emg_get_attachment_id_from_src($imgurl), 'full');
        $tmpimgratio = $attid[2] / $attid[1];
        //get image aspec ratio
        if ($attid[1] > $limiter) {
            $tmph = (int) ($tmpimgratio * $limiter);
            // final image height
            $tmpw = $limiter;
            // fixed image width
            $finimgurl = easymedia_resizer($imgurl, $attid[1], $attid[2], $tmpw, $tmph, true);
            $allimgdata = array($finimgurl, $tmpw, $tmph);
            echo implode(",", $allimgdata);
            wp_die();
        } else {
            $finimgurl = $imgurl;
            $allimgdata = array($finimgurl, $attid[1], $attid[2]);
            echo implode(",", $allimgdata);
            wp_die();
        }
    }
}
function easmedia_custom_columns_easymedia($easymedia_columns, $post_id)
{
    if (is_array(get_post_meta($post_id, 'easmedia_metabox_media_gallery', true))) {
        $ittl = array_filter(get_post_meta($post_id, 'easmedia_metabox_media_gallery', true));
        $ittl = count($ittl);
    } else {
        $ittl = '0';
    }
    switch ($easymedia_columns) {
        case 'psg_thumbnail':
            $mediatype = get_post_meta($post_id, 'easmedia_metabox_media_type', true);
            switch ($mediatype) {
                case 'Single Image':
                    $thumbmedia = get_post_meta($post_id, 'easmedia_metabox_img', true);
                    if (isset($thumbmedia) && $thumbmedia != '') {
                        $globalimgsize = wp_get_attachment_image_src(emg_get_attachment_id_from_src($thumbmedia), 'full');
                        $timthumbimg = easymedia_resizer($thumbmedia, $globalimgsize[1], $globalimgsize[2], 70, 70, true);
                        echo '<img class="imgthumblist" width="70" height="70" alt="Thumbnail" src="' . $timthumbimg . '"></img>';
                    } else {
                        echo '<img class="imgthumblist" width="70" height="70" alt="Thumbnail" src="' . plugins_url('includes/images/no_images.png', __FILE__) . '"></img>';
                    }
                    break;
                case 'Video':
                    echo '<img class="imgthumblist" width="70" height="70" alt="Thumbnail" src="' . plugins_url('images/video.png', __FILE__) . '"></img>';
                    break;
                case 'Audio':
                    echo '<img class="imgthumblist" width="70" height="70" alt="Thumbnail" src="' . plugins_url('images/audio.png', __FILE__) . '"></img>';
                    break;
                case 'Multiple Images (Slider)':
                    echo '<img class="imgthumblist" width="70" height="70" alt="Thumbnail" src="' . plugins_url('images/gallery.png', __FILE__) . '"></img>';
                    break;
            }
            break;
        case 'psg_id':
            echo $post_id;
            break;
        case 'psg_type':
            $mediatype = get_post_meta($post_id, 'easmedia_metabox_media_type', true);
            if (isset($mediatype) && $mediatype != 'Select') {
                if (trim($mediatype) == 'Multiple Images (Slider)') {
                    echo $mediatype . '<br><span class="emgttlimage">Total image(s): ' . $ittl . '</span>';
                } else {
                    echo $mediatype;
                }
            } else {
                echo __('None', 'easmedia');
            }
            break;
        case 'psg_cat':
            $cats = get_the_terms($post_id, 'emediagallery');
            if (is_array($cats)) {
                $item_cats = array();
                foreach ($cats as $cat) {
                    $item_cats[] = $cat->name;
                }
                echo implode(', ', $item_cats);
            } else {
                echo 'Uncategorized';
            }
            break;
        default:
            break;
    }
}
示例#4
0
function emg_thumb_src($img_src, $width, $height, $gsze1, $gsze2)
{
    if (!$img_src) {
        return false;
    }
    if (is_multisite()) {
        return false;
    }
    if (easy_get_option('easymedia_disen_tthumb') == '1') {
        $emg_thumb_url = EMG_THUMB_FILE . "?src=" . $img_src . "&h=" . $height . "&w=" . $width . "&zc=1&q=100";
    } else {
        if ($gsze1 != '0' && $gsze2 != '0') {
            $gsize1 = $gsze1;
            $gsize2 = $gsze2;
        } else {
            $globalsize = wp_get_attachment_image_src(emg_get_attachment_id_from_src($img_src), 'full');
            $gsize1 = $globalsize[1];
            $gsize2 = $globalsize[2];
        }
        $emg_thumb_url = easymedia_resizer($img_src, $gsize1, $gsize2, $width, $height, true);
    }
    return $emg_thumb_url;
}