And how to learn php size img? For example, you need to display the image in this form:

<img src="<?php echo $row['img_url']?>" alt="" width="$width" height="$height"> 

but you do not need to crop the image, you just need to print the size in the img tag, how to do it? I used the example found on the net:

 <?php // ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ массив, содСрТащий Ρ€Π°Π·ΠΌΠ΅Ρ€Ρ‹ изобраТСния $size = getimagesize ("http://smartnews.ru/storage/c/2013/09/06/1378468486_705545_97.jpg"); // Π—Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ Ρ„Π»Π°Π³Π°, // Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΠΎΠ³ΠΎ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠ΅ΠΉ getimagesize() ΠΏΠΎΠ΄ индСксом 2 // послС опрСдСлСния Ρ€Π°Π·ΠΌΠ΅Ρ€Π° изобраТСния $flag = array(1=>'GIF', 2=>'JPG', 3=>'PNG', 4=>'SWF', 5=>'PSD', 6=>'BMP', 7=>'TIFF(Π±Π°ΠΉΡ‚ΠΎΠ²Ρ‹ΠΉ порядок intel)', 8=>'TIFF(Π±Π°ΠΉΡ‚ΠΎΠ²Ρ‹ΠΉ порядок motorola)', 9=>'JPC', 10=>'JP2', 11=>'JPX'); echo "Π¨ΠΈΡ€ΠΈΠ½Π°: " . $size[0] .'<br>'; echo "Высота: " . $size[1] .'<br>'; echo "Π’ΠΈΠΏ изобраТСния: " . $flag[$size[2]] .'<br>'; echo "Π¨ΠΈΡ€ΠΈΠ½Π° ΠΈ Высота: " . $size[3] .'<br>'; ?> 
Here's what happened: enter image description here for which I am grateful to the one who helped

  • Everything you need seems to be already there. I do not understand what prevents it from using. - Arnial
  • just the size is not displayed and everything, namely the img tag is not displayed - user33274
  • In my opinion, it is necessary to rename the topic I do Π½Π΅ ΡƒΠΌΠ΅ΡŽ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒΡΡ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€ΠΎΠΌ echo :-) - Alexey Shimansky
  • Shimansky Alexey, I'm not a prog prog, but sometimes knowledge is required - user33274
  • one
    how they like to put minuses here, I won't turn here anymore, I will compass my brains on SO - they do not stint on explanations and decisions and do it beautifully - user33274

1 answer 1

Everything is beautifully derived:

 <?php $url = "http://smartnews.ru/storage/c/2013/09/06/1378468486_705545_97.jpg"; $size = getimagesize($url); ?> <img src="<?=$url?>" alt="" width="<?=$size[0]?>" height="<?=$size[1]?>"> 

I used the example found on the net.

Programming with Copy + Paste has never led to anything good. We must even at least know the language and understand what you are doing ... Try to explain what is happening here:

 <img src="<?php echo $row['img_url']?>" alt="" width="$width" height="$height"> 
  • thanks, works - I will lay out a work screen - user33274