Jump to content

Recommended Posts

Hi i have some images at my joomla which i want to change with regex.

The string is

<img src="img.png" width="300" height="300">


The width and the height is different every time.

 

i want to change width , height and to add and style="float:right" .

I think you can propose a regex to make it, or some other way to do it.

Its joomla site and the news module is not as i expected.

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/286345-replace-images-width-and-height/
Share on other sites

Its joomla site and the news module is not as i expected.

So you're using a Joomla Module to display news but you dont like how images are displayed on the page? I dont think you need regex is the answer. You just need to edit the template for that module to change how images are displayed.

I did it but it didn't work.

I found the code and i corrected it.

 

here is the code

<?php
$string = '<img src="" width="xx" height="yyy" alt="">';
$new_string = preg_replace('/\<(.*?)(width="(.*?)")(.*?)(height="(.*?)")(.*?)\>/i', '<$1$4$7>', $string);
echo $new_string;
?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.