I wanna make the frontpage of a JOOMLA website look like a blog with the image to the left and the intro text to the right with a readmore link on the bottom.

So far I got it, however the code below grabs the first image of the article and prints it as is with the original size, but I need to basically resize that image in to a 100x150 pixels image.

I don't want to convert the image in to a thumbnail I just want to make the code to add the image width="100px" and height="150px" and also align="left"

FYI this is a template rewrite to the com_content component under category to the blog_item.php file around line 116

So here's my code:

<?php preg_match('/<img (.*?)>/', $this->item->fulltext, $match); ?>
<a href="<?php echo $this->item->readmore_link; ?>"><?php echo $match[0]; ?></a>
<?php echo $this->item->text; ?>

		<?php if ($this->item->params->get('show_readmore') && $this->item->readmore) : ?>
		<p class="readmore">
			<a href="<?php echo $this->item->readmore_link; ?>" class="readmore">
				<?php if ($this->item->readmore_register) :
					echo JText::_('Register to read more...');
				elseif ($readmore = $this->item->params->get('readmore')) :
					echo $readmore;
				else :
					echo JText::sprintf('Read more...');
				endif; ?></a>
		<?php endif; ?>

So far the code below is the one responsible for printing the image

<?php preg_match('/<img (.*?)>/', $this->item->fulltext, $match); ?>
<a href="<?php echo $this->item->readmore_link; ?>"><?php echo $match[0]; ?></a>

The part

<?php echo $match[0]; ?>

prints the full image html code like this

<img alt="Image description" src="http://domain.com/image.jpg"/>

So I need to somehow add this

width="100px" height="150px" align="left"

to it and make it print this way:

<img alt="Image description" src="http://domain.com/image.jpg" width="100px" height="150px" align="left"/>

Please help =)

5 Years
Discussion Span
Last Post by me!

creativity these days...
Not sure if it will do the trick, didn't test

$hack = $match[0];
$cut = "<img";
$image_part = substr($hack,strlen($cut));
$your_image = $cut.'width="100px" height="150px" align="left"'.$image_part;

Edited by Robert1995: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.