Page 1 of 1

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

Posted: Sun Oct 12, 2014 5:39 pm
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

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

Posted: Sun Oct 12, 2014 8:31 pm
by paulbaker
You will probably have to post your News template.

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

Posted: Mon Oct 13, 2014 7:50 am
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.

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

Posted: Mon Oct 13, 2014 8:11 am
by giapippo
thanks
I do a couple of tests
but it seems to work perfectly