WordPress.org

Ready to get started?Download WordPress

Forums

Facebook OpenGraph error, Call to undefined function wp_get_attachment_src() (1 post)

  1. swadeshib
    Member
    Posted 2 years ago #

    Call to undefined function wp_get_attachment_src()

    Object at URL 'http://www.website.com' of type 'article' is invalid because the given value ': Call to undefined function wp_get_attachment_src() in on line Fatal error ...... functions.php123 ' for property 'og:image:url' could not be parsed as type 'url'.

    using this code in header.php

    <meta property="og:image" content="<?php echo get_fbimage(); ?>" />

    in function.php

    <?php
    function get_fbimage() {
    $src = wp_get_attachment_src( get_post_thumbnail_id($post->ID), '', '' );
    if ( has_post_thumbnail($post->ID) ) {
    $fbimage = $src[0];
    } else {
    global $post, $posts;
    $fbimage = '';
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',
    $post->post_content, $matches);
    $fbimage = $matches [1] [0];
    }
    if(empty($fbimage)) {
      $fbimage = "http://www.gogirlfinance.com/wp-content/uploads/2011/03/logo.jpg";
    }
    return $fbimage;
    }
    ?>

    Note: I am using same code/ function in other website with no issue

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags