Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-10-2014, 04:04 PM
devoidfeast devoidfeast is offline
 
Join Date: Jun 2014
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Find First Image or Attachment and replace it with Avatar

Hello Fellows,
I am trying to customize the "Search Widget" where i am replacing the user avatar with a thumbnail.the thumbnail is to be generated from any video or images attached to the post.i am able to write an api call which gets the thumbnail from any video attached but i am still not successful to do it for images and attachment.
Code:
{vb:data thumbnail, content_video, getVideoThumbnail, {vb:raw url}}
<vb:if condition="isset($thumbnail) AND $thumbnail">
				<img src="{vb:raw thumbnail}" alt="" 							
					<vb:if condition="isset($height) AND $height > 0"> height="{vb:raw height}"</vb:if>
					<vb:if condition="isset($width) AND $width > 0"> width="{vb:raw width}"</vb:if>
				/>
			</vb:if>
getVideoThumbnail(url) is method i found in the "core/vb/api/content/video.php". i was successfully able to get the thumbnail from and video embeded.


Now i want to do some thing like the video with photos or [IMG] tag i found a method in the
"core/vb/api/content/text.php"
Code:
function autoPopulatePreviewImage($nodeId)
this function can reads all the post and search for images in it and populate the following array
Code:
		$data = array(
			'parentid' => $node['parentid'],
			'previewimage' => $attachment['nodeid'],
			'nodeoptions' => $node['nodeoptions'], 
		);

How can i call the above api function from a template?

Thank You.
Reply With Quote
  #2  
Old 09-10-2014, 04:55 PM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
{vb:data thumbnail, content_text, autoPopulatePreviewImage, {vb:raw nodeid}}
The nodeid variable would depend on what variable is in scope for the template you're using.
Reply With Quote
  #3  
Old 09-10-2014, 05:10 PM
devoidfeast devoidfeast is offline
 
Join Date: Jun 2014
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i will call it in "display_contenttype_searchwidget_item_header" template.

Code:
{vb:data thumbnail, content_text, autoPopulatePreviewImage, {vb:raw conversation.nodeid}}
--------------- Added [DATE]1410373793[/DATE] at [TIME]1410373793[/TIME] ---------------

thumbnail variable will contain an array?? because autoPopulatePreviewImage() populate an array "data" which contain a possible address to the preview image.after calling the function as follow.
Code:
{vb:data thumbnail, content_text, autoPopulatePreviewImage, {vb:raw conversation.nodeid}}

<img src="{vb:raw thumbnail}" width="32" height="32" alt="{vb:raw conversation.authorname}" />
Now i just get on the avatar the name of the user with image missing.

am i using the thumnail variable wrong?
Reply With Quote
  #4  
Old 09-10-2014, 06:34 PM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, don't have access to the vbulletin source code right now.

Does autoPopulatePreviewImage actually return the array? Or does it use it internally?

If you want to see what's in the variable, you can use:

Code:
{vb:debugvardump thumbnail}
--------------- Added [DATE]1410389539[/DATE] at [TIME]1410389539[/TIME] ---------------

$data isn't returned from the function, so you can't use it to do what you want it to do.
Reply With Quote
Благодарность от:
devoidfeast
  #5  
Old 09-10-2014, 09:53 PM
devoidfeast devoidfeast is offline
 
Join Date: Jun 2014
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the "autoPopulatePreviewImage()" in the api calls to "autoPopulatePreviewImage()" of library
Code:
public function autoPopulatePreviewImage($nodeId)
	{
		$data = $this->library->getFullContent($nodeId);
		if ($this->validate($data, self::ACTION_UPDATE, $nodeId))
		{
			$this->library->autoPopulatePreviewImage($nodeId);
		}
	}
the "autoPopulatePreviewImage()" in the Library does not return anything it also destroys all the variables the only array left ath the end is the following but its not returned.
Code:
		$data = array(
			'parentid' => $node['parentid'],
			'previewimage' => $attachment['nodeid'],
			'nodeoptions' => $node['nodeoptions'], 
		);

if let say at the end i add a line return $data how will i be able to access "$data['previewimage'] " from template page.

thank you
Reply With Quote
  #6  
Old 09-10-2014, 10:22 PM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

{vb:raw thumbnail.previewimage}
Reply With Quote
  #7  
Old 09-10-2014, 10:43 PM
devoidfeast devoidfeast is offline
 
Join Date: Jun 2014
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

great Work. Mr Eddie.
Thank you
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 06:25 AM.


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.05951 seconds
  • Memory Usage 2,229KB
  • Queries Executed 13 (?)
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
  • (9)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (1)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete