Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Upload avatara
lubudubu1010
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 23.07.2014

Ostrzeżenie: (0%)
-----


Witam, mam problem z kodem:

  1. $pathgif = "upload/foto/" . $r['id'] . ".gif";
  2. $pathjpg = "upload/foto/" . $r['id'] . ".jpg";
  3. $pathjpeg = "upload/foto/" . $r['id'] . ".jpeg";
  4. $pathpng = "upload/foto/" . $r['id'] . ".png";
  5. if(file_exists($pathgif)){
  6. echo imageResize($pathgif, 180, 180);
  7. }elseif(file_exists($pathjpg)){
  8. echo imageResize($pathjpg, 180, 180);
  9. }elseif(file_exists($pathjpeg)){
  10. echo imageResize($pathjpeg, 180, 180);
  11. }elseif(file_exists($pathpng)){
  12. echo imageResize($pathpng, 180, 180);
  13. }else{
  14. echo imageResize('upload/foto/quest.jpg', 180, 180);
  15. }


Wgrywanie zdjęć działą dobrze, tylko problemem jest, że zdjęcie wyświetla tylko z rozszerzeniem .gif.
Png, jpg już niestety nie jest wyświetlane.

Z góry dzięki za pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
lubudubu1010
post
Post #2





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 23.07.2014

Ostrzeżenie: (0%)
-----


już podaje:

  1. function imageResize($sImageLocation, $iMaxWidth = 0, $iMaxHeight = 0, $bReturnArray = false) {
  2.  
  3. $aImageSize = getImageSize($sImageLocation);
  4.  
  5. if ($aImageSize[0] > $iMaxWidth && $iMaxWidth != 0) {
  6. $iNewWidth = $iMaxWidth;
  7. $iNewHeight = ($aImageSize[1] / ($aImageSize[0] / $iMaxWidth));
  8. }
  9. if ((isset($iNewHeight) ? $iNewHeight : $aImageSize[1]) > $iMaxHeight && $iMaxHeight != 0) {
  10. $iNewWidth = ((isset($iNewWidth) ? $iNewWidth : $aImageSize[0]) / ((isset($iNewHeight) ? $iNewHeight : $aImageSize[1]) / $iMaxHeight));
  11. $iNewHeight = $iMaxHeight;
  12. }
  13.  
  14. if ($bReturnArray === true) {
  15. return array(
  16. 'image' => $sImageLocation,
  17. 'width' => floor((isset($iNewWidth) ? $iNewWidth : $aImageSize[0])),
  18. 'height' => floor((isset($iNewHeight) ? $iNewHeight : $aImageSize[1]))
  19. );
  20. } else {
  21. return '<img src="'.$sImageLocation.'" width="'.floor((isset($iNewWidth) ? $iNewWidth : $aImageSize[0])).'" height="'.floor((isset($iNewHeight) ? $iNewHeight : $aImageSize[1])).'" alt="" />';
  22. }
  23.  
  24. }
  25.  
  26. function imageResizee($sImageLocation, $iMaxWidth = 0, $iMaxHeight = 0, $title = "") {
  27.  
  28. $aImageSize = getImageSize($sImageLocation);
  29.  
  30. if ($aImageSize[0] > $iMaxWidth && $iMaxWidth != 0) {
  31. $iNewWidth = $iMaxWidth;
  32. $iNewHeight = ($aImageSize[1] / ($aImageSize[0] / $iMaxWidth));
  33. }
  34.  
  35. if ((isset($iNewHeight) ? $iNewHeight : $aImageSize[1]) > $iMaxHeight && $iMaxHeight != 0) {
  36. $iNewWidth = ((isset($iNewWidth) ? $iNewWidth : $aImageSize[0]) / ((isset($iNewHeight) ? $iNewHeight : $aImageSize[1]) / $iMaxHeight));
  37. $iNewHeight = $iMaxHeight;
  38. }
  39.  
  40. if ($bReturnArray === true) {
  41. return array(
  42. 'image' => $sImageLocation,
  43. 'width' => floor((isset($iNewWidth) ? $iNewWidth : $aImageSize[0])),
  44. 'height' => floor((isset($iNewHeight) ? $iNewHeight : $aImageSize[1]))
  45. );
  46. } else {
  47. return '<a href="' . $sImageLocation . '" rel="lightbox[test]" title="' . $title . '"><img src="'.$sImageLocation.'" width="'.floor((isset($iNewWidth) ? $iNewWidth : $aImageSize[0])).'" height="'.floor((isset($iNewHeight) ? $iNewHeight : $aImageSize[1])).'" border="0" alt="" /></a>';
  48. }
  49.  
  50. }
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.10.2025 - 08:21