Page 1 of 1

Tweak inline image styling to divide max-width by half

Posted: Sat Jul 14, 2018 4:00 am
by Najphp
Hello.

I'm not a PHP coder (more frontend dev) but I've been tasked with tweaking some PHP.

Specifically, the client wants to upload double-sized images but still get the image to display at the original size.

At the moment, when an image is uploaded (via a custom image manager) the width of the image is noted and an inline style is generated within a file called ajax_actions.php:

Code: Select all

$obj = new Image($id);

<img src="'.$obj->src().'" title="'.$obj->artist().'" style="max-width:'.$obj->width().'px;"/>
The bit I'm interested in is this:

Code: Select all

style="max-width:'.$obj->width().'px;"
Is there any way of introducing a calculation to halve the size of the uploaded image into the empty brackets following width, e.g.

Code: Select all

$obj->width(/2)
?

Any help would be much appreciated :D

Re: Tweak inline image styling to divide max-width by half

Posted: Mon Jul 16, 2018 10:35 am
by element121
Not in the brackets, but just after:

Code: Select all


$obj->width() / 2 


Re: Tweak inline image styling to divide max-width by half

Posted: Mon Jul 16, 2018 1:09 pm
by Najphp
Great - thanks a lot!