[SOLVED] the og:image in news module is always wrong

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
giapippo
Forum Members
Forum Members
Posts: 176
Joined: Tue Feb 28, 2012 1:24 pm

[SOLVED] the og:image in news module is always wrong

Post by giapippo »

Hello everyone
to display images that load in the news module to use this string
and it works perfectly

<img src="{$entry->file_location}/{$entry->fieldsbyname.immagine->value}" alt="{$entry->title|cms_escape}" />

but in the template if i use this string for the og image

<meta property="og:image" content="<img src="{$entry->file_location}/{$entry->fieldsbyname.immagine->value}" />

the selected image is wrong
and there is but 'that of another news

why
thanks for help

the website is

http://www.teneriecoccolosi.it
Last edited by giapippo on Tue Oct 28, 2014 5:06 pm, edited 1 time in total.
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: the og:image in news module is always wrong

Post by paulbaker »

You will probably have to post your News template.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: the og:image in news module is always wrong

Post by velden »

It's not a good assumption that the $entry variable/object is persistant.

You better assign those values to your own custom smarty variables and use those in the meta tag:

Code: Select all

Somewhere in News template:

{$meta_filelocation=$entry->file_location}
{$meta_filename=$entry->fieldsbyname.immagine->value}

In head section:

<meta property="og:image" content="{$meta_filelocation}/{$meta_filename}" />

Not tested. BTW the 'content="<img src="' should not be in the content attribute of the meta tag.
giapippo
Forum Members
Forum Members
Posts: 176
Joined: Tue Feb 28, 2012 1:24 pm

Re: the og:image in news module is always wrong

Post by giapippo »

thanks
I do a couple of tests
but it seems to work perfectly
Post Reply

Return to “Modules/Add-Ons”