0

I'm new to PHP. I start a website with free ads and what I need is when someone is posting a new ad, all the pictures to be automatically compressed or resized to use less space and to not affect my page load, my website is on PHP, how can I do this? with a script or a PHP code? I find here the code below, will be good? How can I use it?

<IfModule mod_expires.c>
 ExpiresActive On
 ExpiresDefault "access plus 7200 seconds"
 ExpiresByType image/jpg "access plus 2592000 seconds"
 ExpiresByType image/jpeg "access plus 2592000 seconds"
 ExpiresByType image/png "access plus 2592000 seconds"
 ExpiresByType image/gif "access plus 2592000 seconds"
 AddType image/x-icon .ico
 ExpiresByType image/ico "access plus 2592000 seconds"
 ExpiresByType image/icon "access plus 2592000 seconds"
 ExpiresByType image/x-icon "access plus 2592000 seconds"
 ExpiresByType text/css "access plus 2592000 seconds"
 ExpiresByType text/javascript "access plus 2592000 seconds"
 ExpiresByType text/html "access plus 7200 seconds"
 ExpiresByType application/xhtml+xml "access plus 7200 seconds"
 ExpiresByType application/javascript A2592000
 ExpiresByType application/x-javascript "access plus 2592000 seconds"
 ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
</IfModule>
<img src="{{ image.thumb(200, 200, {mode:'auto',quality:85}) }}" title="{{ image.title }}" alt="{{ image.description }}">

my website

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Does this answer your question? [Resize image in PHP](https://stackoverflow.com/q/14649645/3415984) – ttrasn Dec 30 '19 at 09:28
  • The `img` tag appears to have some sort of templating going on - fine if your site employs that technique but otherwise of no use. – Professor Abronsius Dec 30 '19 at 09:56
  • @RamRaider: I imagine it is a feature in the Blade templating format. – halfer Dec 30 '19 at 10:34
  • The easiest way to do this is to let people upload high resolution images, and then run a scheduled process (Cron) that reduces the file size of images whenever it finds a large one. I would say that your first task is to write some PHP code to do the image resizing. – halfer Dec 30 '19 at 10:36
  • @halfer - indeed it probably is ~ my concern was that the OP doesn't use such a system and thus it is of no practical use to them – Professor Abronsius Dec 30 '19 at 10:36
  • Good spot RamRaider. It looks like @MadhuriPatel edited the title to mention Laravel, but it is not clear that Laravel is in use. – halfer Dec 30 '19 at 10:40
  • I have a pretty decent image class that will do the horsework for you https://github.com/delboy1978uk/image – delboy1978uk Dec 30 '19 at 10:40

0 Answers0