MyBB Hacks

Full Version: First post image in the portal?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello friends,

Maybe someone can help me...
I want to show in my portal, only the first image in my post, but I don't know how to make that possible.

I installed this plugin to cut off characters:
http://mods.mybb.com/view/portal-announcement-cut-off

But doesn't work like I want, because a URL can have different numbers of characters...
Unless someone could change the code to appear only the first image inside the [ img ] [ /img] tags.
Is that possible?

PHP Code:
<?php

if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("portal_announcement", "portalannc");



function portalannc_info()
{
	return array(
		"name"			=> "Portal Announcement Cut Off.",
		"description"	=> "It sets a minimum of characters for portal announcements.",
		"website"		=> "http://www.mybb.com/",
		"version"		=> "1.0",
		"author"		=> "bubulang",
		"authorsite"	=> "http://community.mybb.com/user-29135.html",
		"compatibility"  => "16*",
		'guid'        => 'a18f4b6eed189c9ffd4e4708708c15dc'
	);
}

function portalannc_activate()
{
	global $db;
	
	$query = $db->simple_select("settinggroups", "gid", "name='portal'");
	$gid = $db->fetch_field($query, "gid");
	
	$setting = array(
		'name' => 'patcutoff',
		'title' => 'Portal Announcement Cut Off',
		'description' => 'Set a minimum of characters for portal announcements?',
		'optionscode' => 'yesno',
		'value' => 'yes',
		'disporder' => '20',
		'gid' => intval($gid)
	);
	$db->insert_query('settings',$setting);
	
	
	$characters = array(
		'name' => 'characters',
		'title' => 'Characters',
		'description' => 'Number of characters before the announcement is cut off',
		'optionscode' => 'text',
		'value' => '',
		'disporder' => '21',
		'gid' => intval($gid)
	);
	$db->insert_query('settings',$characters);
	
	$cutoffmessage = array(
		'name' => 'cutoffmessage',
		'title' => 'Announcement Cut Off Message',
		'description' => 'Message to be displayed when announcemet is cut off',
		'optionscode' => 'text',
		'value' => '..... More',
		'disporder' => '22',
		'gid' => intval($gid)
	);
	$db->insert_query('settings',$cutoffmessage);
	

rebuild_settings();
}

function portalannc_deactivate()
{
	global $db;

$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='patcutoff'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='characters'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='cutoffmessage'");
    
rebuild_settings();
}
	
function portalannc()	
{
global $mybb, $announcement;

if($mybb->settings['patcutoff'] == 1 AND $mybb->settings['characters'] < my_strlen($announcement['message'])){
$announcement['message'] = my_substr($announcement['message'], 0, $mybb->settings['characters']);
$announcement['message'] .= "[url=".$mybb->settings['bburl']."/".$announcement['threadlink']."]".$mybb->settings['cutoffmessage']."[/url]";
}
}

?>


Can someone help me? Smile
Thank you!

Solved! Thank you anyway Smile
Reference URL's