Home arrow Forum Module code only displays mosimage, trying to get it to display any images. H
  Welcome, Guest. Please login or register.
Did you miss your activation email?
November 22, 2008, 01:52:51 PM
Home New Posts Search Calendar


Login with username, password and session length
+  Joomla Forum
|-+  Joomla Addon Discussion
| |-+  Joomla Modules
| | |-+  Module code only displays mosimage, trying to get it to display any images. H
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: Module code only displays mosimage, trying to get it to display any images. H  (Read 516 times)
dave
Joomla Newbie
*

Karma: +0/-0
Offline Offline

Posts: 1


View Profile
Module code only displays mosimage, trying to get it to display any images. H
« on: May 20, 2007, 01:20:18 PM »

Hi,
Currently the way this module is set up, it only displays an image, if it was put using mosimage (meaning that the image has to be uploaded onto the server).
I want to be able to have it display an image that is from a different server (placed into the post using the add image function) what would I add/change in the following code to enable this. (I think I copied off all the relevant code).

Thanks
Code:
function replaceImage( &$row, $maxchars, $showimage, $width = -1, $height = -1 ) {
global $database, $_MAMBOTS, $current_charset;

// expression to search for
$regex = '/{mosimage\s*.*?}/i';

$image = $showimage?processImage ( $row, $width, $height ):"";
$row->introtext = trim($row->introtext);
$row->introtext = preg_replace( $regex, '', $row->introtext );

$row->introtext1 = strip_tags($row->introtext);
if ($maxchars && strlen ($row->introtext) > $maxchars) {
$row->introtext1 = substr ($row->introtext1, 0, $maxchars) . "...";
}
// clean up globals
return $image;
}

function processImage ( &$row, $width, $height ) {
global $mosConfig_absolute_path, $mosConfig_live_site;

// split on \n the images fields into an array
$row->images = explode( "\n", $row->images );
$img = trim( $row->images[0] );

// split on pipe the attributes of the image
if ( $img ) {
$attrib = explode( '|', trim( $img ) );
// $attrib[0] image name and path from /images/stories

// $attrib[1] alignment
if ( !isset($attrib[1]) || !$attrib[1] ) {
$attrib[1] = '';
}

// $attrib[2] alt & title
if ( !isset($attrib[2]) || !$attrib[2] ) {
$attrib[2] = 'Image';
} else {
$attrib[2] = htmlspecialchars( $attrib[2] );
}

// $attrib[3] border
if ( !isset($attrib[3]) || !$attrib[3] ) {
$attrib[3] = 0;
}

$attrib[4] = '';
$border = 0;

// $attrib[5] caption position
if ( !isset($attrib[5]) || !$attrib[5] ) {
$attrib[5] = '';
}

// $attrib[6] caption alignment
if ( !isset($attrib[6]) || !$attrib[6] ) {
$attrib[6] = '';
}

// image size attibutes

// assemble the <image> tag
$image = '<img src="'. $mosConfig_live_site .'/images/stories/'. $attrib[0] .'"';
// no aligment variable - if caption detected
if ( !$attrib[4] ) {
$image .= $attrib[1] ? ' align="'. $attrib[1] .'"' : '';
}
$image .=' alt="'. $attrib[2] .'" title="'. $attrib[2] .'" border="'. $border .'" '. (($width != -1) ? 'width="'. $width . '"' : '') .(($height != -1) ? ' height="'. $height .'"' : '').' />';

$img = $image;
}
return $img;
Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Joomla Forum | Powered by SMF 1.1 RC1.
© 2001-2005, Lewis Media. All Rights Reserved.
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!

Joomla Hacks is a Joomla Components, Joomla Modules, Joomla Templates, & Joomla Mambots resource portal. None of the text or images in this public website may be copied without the expressed written consent of the authors. Copyright 2005 by JoomlaHacks.com. Powered by Joomla. All rights reserved.
Terms of Use
Joomla Hacks



Joomla Hacks
German Lang French Lang Italian Lang Spanish Lang Japanese Lang Chinese Lang
Search Contact About Advertise Blogs Topsites Submit News Register Login