First post image in the portal?
Divvy Offline
Junior Member
**
Posts: 37
Joined: Jan 2012
Post: #1
First post image in the portal?
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?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!

01-28-2012 02:56 AM
Find all posts by this user Quote this message in a reply
Divvy Offline
Junior Member
**
Posts: 37
Joined: Jan 2012
Post: #2
RE: First post image in the portal?
Solved! Thank you anyway Smile
01-28-2012 04:15 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: