Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2015-10-10 23:23:46, last edited by ParadoxInTheVoid (2015-10-10 23:25:49)

ParadoxInTheVoid
Member
From: ̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺
Joined: 2015-02-18
Posts: 341

PHP Resize All Images Proportionally

I have a web thing I'm working on and I need to resize all images that show up on the page to 1/4 or a 1/2 of their actual size.

If this code could be incorporated into this, that'd be great:

<?php
     $files = glob("../x/*.*");
     
     for ($i=1; $i<count($files); $i++) {
          $image = $files[$i];
          $supported_file = array(
               'gif',
               'jpg',
               'jpeg',
               'png'
     );

     $ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
     if (in_array($ext, $supported_file)) {
          echo '<img src="'.$image .'" style="" alt="x" />'."";
     } else {
          continue;
     }
}
?>

signature.png

Offline

#2 2015-10-10 23:43:17

ewoke
Member
Joined: 2015-02-20
Posts: 412

Re: PHP Resize All Images Proportionally

not really sure but couldnt you use html to do this? <img src="topkek.png" style="width:50%; height:50%;"/>


if you can read this....good for you

Offline

#3 2015-10-10 23:47:31

ParadoxInTheVoid
Member
From: ̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺
Joined: 2015-02-18
Posts: 341

Re: PHP Resize All Images Proportionally

ewoke wrote:

not really sure but couldnt you use html to do this? <img src="topkek.png" style="width:50%; height:50%;"/>

The image shows up a little messed up when i do it like that //forums.everybodyedits.com/img/smilies/tongue The image looks stretched.


signature.png

Offline

#4 2015-10-10 23:50:07

ParadoxInTheVoid
Member
From: ̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺
Joined: 2015-02-18
Posts: 341

Re: PHP Resize All Images Proportionally

You know what, wow, I just needed to do <img src="image.png" style="width: 32px; height: auto;" />
I feel kinda stupid now.


signature.png

Offline

#5 2015-10-10 23:51:40

ewoke
Member
Joined: 2015-02-20
Posts: 412

Re: PHP Resize All Images Proportionally

haha good job, keep focussing on your stuff //forums.everybodyedits.com/img/smilies/wink


if you can read this....good for you

Offline

#6 2015-10-11 01:17:08

Different55
Forum Admin
Joined: 2015-02-07
Posts: 16,575

Re: PHP Resize All Images Proportionally

ParadoxInTheVoid wrote:
ewoke wrote:

not really sure but couldnt you use html to do this? <img src="topkek.png" style="width:50%; height:50%;"/>

The image shows up a little messed up when i do it like that //forums.everybodyedits.com/img/smilies/tongue The image looks stretched.

Side note: that's because CSS width and height aren't relative to the "natural" width and height of the element it's attached to, it's relative to the containing element's width and height.


"Sometimes failing a leap of faith is better than inching forward"
- ShinsukeIto

Offline

Different551444522628548377

Board footer

Powered by FluxBB

[ Started around 1738978280.4113 - Generated in 0.035 seconds, 12 queries executed - Memory usage: 1.42 MiB (Peak: 1.53 MiB) ]