Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2017, 06:39 PM
SilverBoy SilverBoy is offline
 
Join Date: Feb 2002
Location: Libya
Posts: 497
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 01-03-2017, 06:56 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Assuming you have the user's userid in $userid, you can get the URL of their profile pic as follows:

PHP Code:
$ppuserinfo fetch_userinfo($userid8);

if (
$vbulletin->options['usefileavatar'])
{
    
$ppuserinfo['profilepicurl'] = $vbulletin->options['profilepicurl'] . '/profilepic' $ppuserinfo['userid'] . '_' $ppuserinfo['profilepicrevision'] . '.gif';

    if (!
file_exists($ppuserinfo['profilepicurl']))
    {
        
$ppuserinfo['profilepicrevision'] = 0;
    }
}
else
{
    
$ppuserinfo['profilepicurl'] = 'image.php?' $vbulletin->session->vars['sessionurl'] . 'u=' $ppuserinfo['userid'] . "&dateline=$ppuserinfo[profilepicdateline]&type=profile";
}

$profilepicexists $ppuserinfo['profilepicrevision'] OR $ppuserinfo['profilepicdateline']; 
Now, if the variable $profilepicexists evaluates to true, the URL of the profile pic is in $ppuserinfo['profilepicurl'].
Reply With Quote
  #3  
Old 01-03-2017, 06:59 PM
SilverBoy SilverBoy is offline
 
Join Date: Feb 2002
Location: Libya
Posts: 497
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 !!
Reply With Quote
  #4  
Old 01-03-2017, 07:05 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
if ($profilepicexists)
{
    
$opengraph['profilepicurl'] = $ppuserinfo['profilepicurl'];

Reply With Quote
  #5  
Old 01-03-2017, 07:11 PM
SilverBoy SilverBoy is offline
 
Join Date: Feb 2002
Location: Libya
Posts: 497
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I want to use og:image property.
Reply With Quote
  #6  
Old 01-03-2017, 07:20 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SilverBoy View Post
I want to use og:image property.
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.
Reply With Quote
  #7  
Old 01-03-2017, 07:23 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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}" />
Reply With Quote
  #8  
Old 01-03-2017, 07:24 PM
SilverBoy SilverBoy is offline
 
Join Date: Feb 2002
Location: Libya
Posts: 497
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default


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:
 $ppuserinfo fetch_userinfo($userid8); 
Sorry, #8 here what is mean?
Reply With Quote
  #9  
Old 01-03-2017, 07:33 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
if ($profilepicexists)
{
    
vB_Template::preRegister($template_name, array('profilepicurl' => $ppuserinfo['profilepicurl']));

Reply With Quote
  #10  
Old 01-03-2017, 07:39 PM
SilverBoy SilverBoy is offline
 
Join Date: Feb 2002
Location: Libya
Posts: 497
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
$ppuserinfo fetch_userinfo($userid8);

if (
$vbulletin->options['usefileavatar'])
{
    
$ppuserinfo['profilepicurl'] = $vbulletin->options['profilepicurl'] . '/profilepic' $ppuserinfo['userid'] . '_' $ppuserinfo['profilepicrevision'] . '.gif';

    if (!
file_exists($ppuserinfo['profilepicurl']))
    {
        
$ppuserinfo['profilepicrevision'] = 0;
    }
}
else
{
    
$ppuserinfo['profilepicurl'] = 'image.php?' $vbulletin->session->vars['sessionurl'] . 'u=' $ppuserinfo['userid'] . "&amp;dateline=$ppuserinfo[profilepicdateline]&amp;type=profile";
}

$profilepicexists $ppuserinfo['profilepicrevision'] OR $ppuserinfo['profilepicdateline'];
if (
$profilepicexists)
{
    
vB_Template::preRegister(vbcms_content_article_page, array('profilepicurl' => $ppuserinfo['profilepicurl']));

--------------- Added [DATE]1483479854[/DATE] at [TIME]1483479854[/TIME] ---------------

It didn't work !!

Here is what I get in my source code
HTML Code:
<meta property="og:image" content="" />
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07399 seconds
  • Memory Usage 2,281KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_html
  • (5)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete