og: image with bank image - symfony php

0

Hi, I have a news page that the user can enjoy and share the news. Every news has its specific image. In some news there is a specific photo album. When there is the album for news, facebook sharing picks up an album image and not the news image.

I searched around and found that I should use the og: image meta tag, but I just can not do that, just look at my code

The image is inserted in the news table. no action:

$this->imagem = Doctrine_core::getTable('tbnews')
                ->createQuery('im')
                ->select('im.id, im.imagem')
                ->where("im.imagem != ''")
                ->andWhere('im.id = ', $request->getParameter('id'))
        ->limit(1)
        ->execute();

    $response = $this->getResponse();
    $response->addMeta("og:image", "http://www.meusite.gov.br/upload/noticias/<?php echo $this->imagem;");

And that's what I get for page rendering:

<meta content="http://www.meusite.gov.br/upload/noticias/<?php echo <pre> Doctrine_Collection data : Array( 0 : Object(tbNews) ) </pre>; ?>" name="og:image">
    
asked by anonymous 09.11.2015 / 13:39

2 answers

0

Change the:

$response->addMeta(
    "og:image",
    "http://www.meusite.gov.br/upload/noticias/<?php echo $this->imagem;"
);

... by:

$response->addMeta(
    "og:image",
    "http://www.meusite.gov.br/upload/noticias/" . $this->imagem->getAtributo()
);

In the above example I used a getAtributo() method (which probably does not exist) of class tbnews to print this attribute in the meta tag. Change the method to another one of your choice.

    
09.11.2015 / 13:49
0

I found the solution. I had to rewrite the addMeta () function so that the name parameter was replaced with property .

    
09.11.2015 / 17:42