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; ?>

		</div>
		<?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>
		</p>
		<?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 =)

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;

Thanks! I'll try it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.