Please upgrade here. These earlier versions are no longer being updated and have security issues.

embedding links from metadata

This discussion is related to the OEmbed addon.
edited November 2015 in Vanilla 2.0 - 2.8

Hi,

This plugin is creating embeddable content for all links. Not just the ones in the user posts.

This includes, any links in the og metadata http://ogp.me/
These are located between the <head> tags of the page.

The causes (I suspect) are specifically these tags:

<head>
....
<meta property="og:description" content="look: http://imgur.com/gallery/C99i3pW">
<meta name="description" property="og:description" itemprop="description" content="look: http://imgur.com/gallery/C99i3pW">
...
</head>

The obvious solution would be to only search for URLs in the <body> tag (or a particualy set of divs).

However my programming knowledge is limited, and vanilla documentation is somewhat sparse.
Any help/tips will be appreciated.

The code i have to modify is probably here (class.oembed.plugin.php):

    public function base_links_handler($sender, $args)
    {
        $self = $this;

        $mixed =& $args['Mixed'];

        // Include Composer autoloader
        $this->getResource('library/vendors/autoload.php', true);

        // Get instance of Essence library
        $essence = \Essence\Essence::instance();

        // Replace links with embedable HTML
        $mixed = $essence->replace($mixed, function($media) use ($self) {
            $slug = str_replace(' ', '', ucwords($media->providerName));

            $media->set('providerSlug', $slug);

            include $self->getView($media->type.'.php');
        });
    }

cheers

Comments

  • BTW, is there a way to disable the open graph stuff?

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    I do not see any changes in the meta area before/after enabling the plugin.

    But it will not be able to handle only body links the way the plugin works right now. You can check for special properties and decide not to change anything if you know of a "pattern" to exclude links.


  • Thanks for the reply. It only happens when the content is in the first 300 chars of the first post.

    I am thinking of solutions that I will try to implement in my spare time. Tips/feedback welcome.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    As far as I can see, the library that kasper used could also parse texts. So you could hook into the BeforeSave event and change the links in postings before they are saved to the db.


Sign In or Register to comment.