The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Adding user profile picture to open graph
Hi
In my CMS articles I displays the avatars of the author of the article, but because the image is small (60×60 px) Facebook didn't grab it when I share the link to Facebook. So I think in adding user profile picture (Big size) as a variable to the opengraph array. The question is .. How I can get the profile picture in every article? then how I can add it to opengraph array? Thanks in advance. |
#2
|
||||
|
||||
Assuming you have the user's userid in $userid, you can get the URL of their profile pic as follows:
PHP Code:
|
#3
|
|||
|
|||
Thank you mark, I will give it a try, but how I can inject the profilepic to the opengraph array?
I tried it manually by adding link to the image in the top of vbcms_content_article template but Facebook ignore it and don't add it to the og:images !! |
#4
|
||||
|
||||
I don't know what key you wish to use for the $opengraph array, but suppose with wish to use the key "profilepicurl', then you could add:
PHP Code:
|
#5
|
|||
|
|||
I want to use og:image property.
|
#6
|
||||
|
||||
I don't know what that is...I thought you wanted to store the URL of the profile pic in the specified array.
I have negligible experience with the CMS articles feature of vB, but I thought I would be able to give you a leg up on getting the data you want into the array. |
#7
|
||||
|
||||
After a quick google search, it appears you need a meta tag in your template, and you will have to register the URL variable for your template, and your meta tag would then look something like:
HTML Code:
<meta property="og:image" content="{vb:raw profilepicurl}" />
|
#8
|
|||
|
|||
When you share a link in FB, the image that appears as thumbnail comes from this property. If you open any page in sharing debugger tools you will see all properties that FB uses from your page. https://developers.facebook.com/tools/debug/sharing/ --------------- Added [DATE]1483478739[/DATE] at [TIME]1483478739[/TIME] --------------- Stupid Q How I can register the variable? --------------- Added [DATE]1483479009[/DATE] at [TIME]1483479009[/TIME] --------------- PHP Code:
|
#9
|
||||
|
||||
Suppose you have the name of the template to which you wish to send the variable in $template_name, then in your plugin, you could use
PHP Code:
|
#10
|
|||
|
|||
Here is my plugin, is it right?
Hook: vbcms_article_populate_end(vbulletin cms) Name: Add profile picture as meta tag Order: 5 Code: PHP Code:
It didn't work !! Here is what I get in my source code HTML Code:
<meta property="og:image" content="" />
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|