Found bug in metatag module

Ken Rich
Ken Rich
@ken-rich
3 years ago
926 posts
It appears that the module needs an update. It is generating tags with the outdated name convention rather than property. Therefore the tags specified by the module are being ignored.

For example, the Facebook Debugger is giving this error on a URL where I used the module to generate tags.

Tag specified as 'name' instead of 'property'
The following meta tags are specified using 'name' instead of 'property' and will be ignored unless specified using the 'property' key: og:image, og:description

It appears these tags are also being ignored in Yahoo mail too as the wrong OG image is being pulled even though it is specified by the module.


--

Ken Rich
indiegospel.net

updated by @ken-rich: 10/31/21 10:04:28AM
michael
@michael
3 years ago
7,717 posts
We've updated the meta.tpl in the next version of the jamroom skins, the change is:
{if isset($meta)}
{foreach from=$meta key="mname" item="mvalue"}
<meta name="{$mname}" content="{$mvalue}">
{/foreach}
{/if}
got changed to this:
{if isset($meta)}
{foreach from=$meta key="mname" item="mvalue"}
<meta name="{$mname}" property="{$mname}" content="{$mvalue}">
{/foreach}
{/if}
Ken Rich
Ken Rich
@ken-rich
3 years ago
926 posts
Ah - I know exactly where that spot is. That's where I added an else to get my profile index to have meta tags.
Thanks...


--

Ken Rich
indiegospel.net
Ken Rich
Ken Rich
@ken-rich
3 years ago
926 posts
Hmmmm... I did a test using the new code in the meta.tpl

I used the metatag module to change the OG image for this page - https://indiegospel.net/submissions

At the Facebook debugger I did see the image change but I still got the same error that the OG image was specified by name instead of property and would be ignored. Still, it inferred the right image.

What the scraper saw exactly was:

<meta name="og:image" property="og:image" content="https://indiegospel.net/profile/image/profile_image/1301/original/_v=1499964721">

I'm thinking the code might need to be adjusted to leave out meta name altogether and just use property?

{if isset($meta)}
{foreach from=$meta key="mname" item="mvalue"}
<meta property="{$mname}" content="{$mvalue}">
{/foreach}
{/if}

Am I out in left field or does that seem like it might work?


--

Ken Rich
indiegospel.net
michael
@michael
3 years ago
7,717 posts
The facebook debugger is reporting that page's og:image is fine, its complaining you're missing other different tags.
face.jpg
face.jpg  •  1.6MB

Ken Rich
Ken Rich
@ken-rich
3 years ago
926 posts
Hi Michael,

If you click "Show All Warnings" it then shows that the OG image is being ignored. I'll copy and paste the warnings plus attach as a screenshot.

caution-solidWarnings That Should Be Fixed
Missing Properties
The following required properties are missing: og:url, og:type, og:title, fb:app_id
Tag specified as 'name' instead of 'property'
The following meta tags are specified using 'name' instead of 'property' and will be ignored unless specified using the 'property' key: og:image, og:description

===========================

The noteworthy part (for me) is that the og:image is being ignored and the reason why is given. This is despite the fact that I just changed the og:image using the metatag manager with the new code installed in the meta.tpl
og-image.PNG
og-image.PNG  •  41KB




--

Ken Rich
indiegospel.net
Ken Rich
Ken Rich
@ken-rich
3 years ago
926 posts
I have done more experiments and confirmed that the code should be:

{if isset($meta)}
{foreach from=$meta key="mname" item="mvalue"}
<meta property="{$mname}" content="{$mvalue}">
{/foreach}
{/if}

If you include the name= key either before or after the property= key, the Facebook debugger gives this warning for all tags specified.

"The following meta tags are specified using 'name' instead of 'property' and will be ignored unless specified using the 'property' key: "

I have my meta.tpl altered accordingly, with only property, no name key. I created all the required tags for my test page and the Facebook Debugger is no longer ignoring them and giving the warning above.

If I do the code the way Jamroom is suggesting for the proposed meta.tpl revision, I get a warning that the tags are being ignored and are therefore inferred from whatever exists on the page.


--

Ken Rich
indiegospel.net
Ken Rich
Ken Rich
@ken-rich
3 years ago
926 posts
The "proof is in the pudding" as they say.
This is my test page - https://indiegospel.net/submissions


--

Ken Rich
indiegospel.net
Ken Rich
Ken Rich
@ken-rich
3 years ago
926 posts
Not to complicate the above (which will work well for most Jamroom users), I have added an "else" statement to the code in the meta.tpl to take care of the profile index pages.

{if isset($meta)}
{foreach from=$meta key="mname" item="mvalue"}
<meta property="{$mname}" content="{$mvalue}">
{/foreach}
{else}
{if $current_url == "{$jamroom_url}/{$profile_url}"}
{jrCore_include template="profile_meta.tpl"}
{/if}
{/if}

The code for the profile_meta.tpl I added to skins made available to normal profiles is:

{jrCore_module_url module="jrProfile" assign="murl"}
<meta property="og:title" content="{$profile_name}" />
<meta property="og:url" content="{$current_url|replace:"http:":"`$method`:"}" />
<meta property="og:type" content="website" />
			{capture name="aboutuser" assign="aboutuser_row"}
			    {literal}
			        {if isset($_items)}
			            {foreach $_items as $item}
            			    {$item.user_signup_question_2}
			            {/foreach}
			        {/if}
			    {/literal}
			{/capture}
{jrCore_list module="jrUser" profile_id=$_profile_id template=$aboutuser_row assign="abtuser"}         
 {if isset($abtuser) && strlen($abtuser) > 0}			    
<meta property="og:description" content="{$abtuser|jrCore_strip_html|jrCore_entity_string|truncate:300}" />	  	
{/if}
<meta property="og:image" content="{$jamroom_url}/{$murl}/image/profile_image/{$_profile_id}/xlarge" />
<meta property="og:updated_time" content="{$smarty.now}" />


I added a different profile_meta.tpl into the skins made available to profiles created by power users. This is because the "about us" is from the user account and not specific to the individual profiles created by it. So the "bio" field is specified instead of the "about us" for those profiles.

{jrCore_module_url module="jrProfile" assign="murl"}
<meta property="og:title" content="{$profile_name}" />
<meta property="og:url" content="{$current_url|replace:"http:":"`$method`:"}" />
<meta property="og:type" content="website" />
{if isset($profile_bio) && strlen($profile_bio) > 0}
<meta property="og:description" content="{$profile_bio|jrCore_strip_html|jrCore_entity_string|truncate:300}" />
{/if}
<meta property="og:image" content="{$jamroom_url}/{$murl}/image/profile_image/{$_profile_id}/xlarge" />
<meta property="og:updated_time" content="{$smarty.now}" />

I am finding that this approach works quite well for my needs though I suspect a "real programmer" could find a more "elegant" solution.


--

Ken Rich
indiegospel.net