Monday, 15 April 2013

php - How can i automatically generate thumbnails on a web server? -


I am hosting a web server full of images Theese are programatically loaded via php 100 10 MB files I have created thumbnails to prevent loading if I want to upload a new image now, so I need to manually create thumbnails. Can I upload it to the server automatically once, or once Php can find out that the thumbs are missing?

If u need the code then i am still:

  function getThumb ($ file) {// strip file below its name // $ suffix = pathfow ($ file, pATHINFO_EXTENSION); // Depricated // $ filename = basename ($ file); // Depricated $ Filename = pathinfo ($ file, PATHINFO_FILENAME); $ Thumbpath = "imgirs / posts / thumbs"; $ Thumbnail = $ thumbpath $ Filename ".jpg"; Return $ thumbnail; } // image loader // contains images containing folder $ Filedir = "imgres / posts /"; Retrieve images in the // folder. $ Picture = Globe ($ filed. * * .JPG, JPG, PNG, PNG, GIF, GIF} ", GLOB_BRACE); // Ensure that the image array is not empty, or if taped (! {// Load images in website Foreign currency ($ image as $ images) {if (path image ($ image, PATINFO_EXTENSION) == "GIF" || Pathinfo ($ image, PATHINFO_EXTENSION) {echo '& Lt; a href = "' $ Image '"& Gt; & lt; img src ="'. $ Image. "" /> Gt; & lt; / a & gt; ';} Else {echo & lt; a href = "'. $ Image. '"& Gt; & lt; img src ="'. GetThumb ($ Image). "" /> Gt; & Lt; / A & gt; '; }}} {// Write an error message to warn users. Echo "& lt; p & gt; No image was found in the server. It is most likely that there is an error in the PHP code, there is an incompatibility, or something went wrong with our storage solution. : Browser, OS, and Site worked first? & Lt; / p & gt; "; }  " 

I found a class called Simple Image by Cloviska. And my code has been done all this looks like this.

which takes care of thumbnails:

  is the function thumb ($ thumbnail) {return file_exists ($ thumbnail); } Function methoshomb ($ origin, $ destination) {$ img = new abeautifulsite \ SimpleImage ($ original); $ Img- & gt; Fit_to_width (256); $ Img- & gt; ($ Destination); }? & Gt;  

Image that loads:

   & Lt; / A & gt; '; } Else {echo & lt; A href = "'. $ Image.'" & Gt; & Lt; Img src = "'. GetThumb ($ Image)." "/> Gt; & lt; / a & gt; ';}}} {// Write an error message to alert the user. The echo" & lt; P & gt; No image was found in the server. It is most likely that the PHP code has an error, is incompatible, or something went wrong with our storage solution. Contact the administrator: Required information: Browser, OS, and site worked before? & Lt; / P & gt; ";}? & Gt;  

No comments:

Post a Comment