Esempio n. 1
0
function lm_add_feature_image_to_rss($content)
{
    global $post;
    $img_id = false;
    // From post meta, custom field
    $key = apply_filters("rss_image_meta_key", "blog-image");
    if ($key && ($i = get_post_meta(get_the_ID(), $key, true))) {
        $img_id = image_get_attachment_id($i);
    }
    // Fall back to featured image
    if (!$img_id) {
        $img_id = get_post_thumbnail_id();
    }
    // Fall back to first image from post content
    if (!$img_id && ($i = auto_archive_image())) {
        if ($i) {
            $img_id = image_get_attachment_id($i);
        }
    }
    // If we have an image URL, attach it
    if ($img_id) {
        $full_size = smart_media_size((int) $img_id, has_image_size('rssfeed-landscape') ? 'rssfeed-landscape' : 'medium');
        $type = 'image/jpg';
        if (substr($full_size, -3) == 'png') {
            $type = 'image/png';
        }
        echo "\t";
        echo sprintf('<media:content url="%s" medium="image" width="560" height="280" type="%s" />', esc_attr($full_size), esc_attr($type));
        echo "\n";
    }
}
Esempio n. 2
0
function ld_seo_meta()
{
    $description = get_bloginfo('description', 'display');
    if (is_single()) {
        if ($d = get_post_meta(get_the_ID(), 'description', true)) {
            $description = $d;
        } else {
            if ($d = get_the_excerpt()) {
                $description = wp_strip_all_tags($d);
            }
        }
    }
    if (!$description) {
        if (is_front_page()) {
            $description = get_bloginfo('description');
        }
    }
    ?>
<meta name="description" content="<?php 
    echo esc_attr($description);
    ?>
" />
<?php 
    // Also display open graph tags, unless we opt to skip this section.
    // The SEO Ultimate will skip this if it is running, via plugin-seo-ultimate.php
    if (apply_filters('ld_disable_open_graph', true) == false) {
        return;
    }
    $metadata = array('og:description' => $description, 'og:image' => '', 'og:type' => 'article', 'og:title' => '', 'og:site_name' => '');
    // Display an open graph image. Priority:
    // 1. Featured Image
    // 2. Image from post meta url or ID, "featured-image"
    // 3. First image from body content
    // 4. Fall back to theme open graph image
    // 5. Fall back to logo
    if (is_singular()) {
        $metadata['og:image'] = auto_archive_image(get_the_ID(), 'full');
    }
    if (!$metadata['og:image']) {
        $metadata['og:image'] = smart_media_size((int) get_field('open_graph', 'options', false), 'full');
    }
    if (!$metadata['og:image']) {
        $metadata['og:image'] = smart_media_size((int) get_field('logo', 'options', false), 'full');
    }
    $metadata['og:image'] = apply_filters('forest_og_image', $metadata['og:image']);
    // Other data
    $metadata['og:title'] = get_the_title();
    $metadata['og:site_name'] = get_bloginfo('title');
    // Other og tags
    unset($metadata['description']);
    foreach ($metadata as $k => $v) {
        if (!$v) {
            continue;
        }
        echo "<meta name=\"" . esc_attr($k) . "\" content=\"" . esc_attr($v) . "\" />\n";
    }
}