Images ALT tag in a text file retrieve by php -
I set up a small gallery based on
I am trying to give this gallery an ultimate tag. Using Picture File Names I need a way to use the text file associated with my images, something like this: myprettypicture.jpg = "Here is a beautiful picture" mynotsoprettypicture.jpg = "There is not a very beautiful picture here"
Then put the tag in the form of ALT with the php gallery For the To retrieve it. So far, I have seen in many galleries and some are using this method, but I do not know how to use it with my actual gallery ...
Do you have a script or simple Do I close the law?
Thanks!
If I understand you correctly, then you get a source_file HTMT as the source below. has gone.
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Body & gt; & Lt; Img src = "myprettypicture.jpg" alt = "myprettypicture.jpg" height = "50" width = "50" & gt; & Lt; Img src = "mynotsoprettypicture.jpg" alt = "mynotsoprettypicture.jpg" height = "50" width = "50" & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Now, it is better to replace the replacement of your images with a replacement tag in an images.ini
file.
myprettypicture.jpg = "Here's a beautiful picture" mynotsoprettypicture.jpg = "There is not a very beautiful picture here"
Now you can use this PHP script Can run:
& lt ;? Php $ ini_array = parse_ini_file ("images.ini"); // load "images.ini" in the array foreach ($ ini_array $ key = & gt; $ val) {$ img [] = 'alt = "'. $ '' '' '; $ Alt [] =' Alt = ''. $ Val. ' Get your "source_file.htm" $ source = file_get_contents ('source_file.htm'); $ target = str_replace ($ img, $ alt, $ source); // All required replacements file_put_contents ( 'Target_file.htm', target $ target; // save the result "target_file.htm"? & Gt; target_file.htm
& lt; html> gt; body & gt; & lt; img src = "myprettypicture.jpg" alt = "Here's a beautiful Picture is "height =" 50 "width =" 50 ">
Reference: ,, ,
Comments
Post a Comment