The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Joomla - Php alt tag in images dont work
Discuss Php alt tag in images dont work in the PHP Development forum on Dev Shed. Php alt tag in images dont work PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 25th, 2013, 02:54 PM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
|
Joomla - Php alt tag in images dont work
Hello.
I use some components to instal games, flash games, and on web site their is a pictures of each games. But on pictures missing alt, and tittle tags. :S Tittle are not writed, but if know hav to insert tittle like alt tag, it would be great.
Hier is code for this:
PHP Code:
<?php
///////////////////////////////////////
// DROPDOWN ORDER END
///////////////////////////////////////
///////////////////////////////////////
// GAMES BOXES START
///////////////////////////////////////
$db =& JFactory::getDBO();
for($i=0;$i<count($this->games);$i++) {
$game=$this->games[$i];
$slug=$game->slug;
$game->imgname=$this->params->get('dir_swf').$slug.'/'.$game->imgname;
$game->description=$db->getEscaped($game->description);
$game->description=str_replace("\\\"","\'",$game->description);
$game->namett=$db->getEscaped($game->name);
?>
<div class="game" style="text-align:center;">
<a style="border:0;" href="<?php echo JRoute::_('index.php?option=com_yoflash&view=game&id='.$slug.'&Itemid='.$this->Itemid); ?>" onmouseover="Tip('<strong><?php echo $game->namett; ?></strong><br/> <?php echo $game->description; ?>',WIDTH,300,FADEIN,0,DELAY,0,BGCOLOR, '<?php echo $this->params->get('ttip_bgcolor'); ?>', BORDERCOLOR,'<?php echo $this->params->get('ttip_bordercolor'); ?>',FONTCOLOR,'<?php echo $this->params->get('ttip_fontcolor'); ?>',FONTSIZE,'<?php echo $this->params->get('ttip_fontsize'); ?>',FONTFACE,'<?php echo $this->params->get('ttip_fontface'); ?>')" onmouseout="UnTip()">
<img src="<?php echo $game->imgname; ?>" width="100" height="100" alt="<?php echo $game->name; ?>"/><br/>
<?php echo $game->name; ?>
</a>
</div>
<?php
}
And this i get:
Code:
<a onmouseout="UnTip()" onmouseover="Tip('<strong>Alaska Jigsaw</strong><br/> Alaska Jigsaw are puzzle game in which you use the mouse to piece together few pictures of Alaska.',WIDTH,300,FADEIN,0,DELAY,0,BGCOLOR, '#E2E7FF', BORDERCOLOR,'#003099',FONTCOLOR,'#000044',FONTSIZE,'8pt',FONTFACE,'Verdana,Geneva,sans-serif')" href="/alaska-jigsaw.html" style="border:0;"><img width="100" height="100" alt="" src="/images/games/alaska-jigsaw/alaskajigsaw.jpg"></img><br></br>
Alaska Jigsaw
</a></div>
As i can see all work, except this with alt tag,
this code
PHP Code:
alt="<?php echo $game->name; ?>"
give and this
PHP Code:
<?php echo $game->name; ?>
give name of games. Which i whant to be in alt tags too, but on this part dont work. :S Please help.
|

February 25th, 2013, 02:57 PM
|
 |
Likely to be eaten by a grue.
|
|
Join Date: Oct 2006
Location: Pennsylvania, USA
|
|
|
Why not just use $game->namett? That seems to be working.
Also, your style is wrong. That's not how you do CSS styles at all.
__________________
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
|

February 25th, 2013, 03:28 PM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
|
This is not my php code, i use from one components for adding games.
I tray to add $game->namett but then i dont name of games, i get images name. :S Which look somethin like this games_112921'12 and like this.I dont know haw code write name on the last sections great, and in alt="" same code do not work. :S What is this?
|

February 25th, 2013, 03:55 PM
|
 |
Likely to be eaten by a grue.
|
|
Join Date: Oct 2006
Location: Pennsylvania, USA
|
|
PHP Code:
$game->namett=$db->getEscaped($game->name);
That's how game->namett gets set. If you're saying it's an image name, you have more problems than i can fix with just this small snippet.
|

February 26th, 2013, 02:49 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
This should put name of games inside the alt tags in images, but it puts image names. :S Which sometimes look strange, and not seo friendly. I dont understand whay this code
PHP Code:
<?php echo $game->name; ?>
put game name, when are out from "", and inside alt="" dont write nothing. Did "" means somthing in php?
|

February 27th, 2013, 05:54 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
Quote: | Originally Posted by animation a speaking navigation plugin for for Joomla! 1.5 allowing you to insert additional text to your menu items. Features list Nonspeaking you can set several parameters: * Tag: Choose which HTML tag is used to display text. Default. |
What? I do not use Joomla 1.5, and what this have with no alt tag showing? I dont whant to insert aditional text in menu items, i whant to know whay code for showing some text do not work as it work on rest part.
|

February 27th, 2013, 06:36 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
You're talking to a spam bot. See the red "Warnings Level" and "Number of bans" in the top right corner? That's an indicator for spam.
Apart from that, this all doesn't make sense. So $game->name is something like "Alaska Jigsaw", but $db->getEscaped($game->name) suddenly returns the name of the image in the form "games_112921'12"??
Either you're totally mixing up the values, or your code is really, really broken. A database escaping function that magically turns names into file names doesn't work quite ... correctly.
I suggest two things: - Fix your code. Instead of having all kinds of unescaped and escaped values (which overwrite the unescaped attributes), leave the attributes as they are and escape them right before you echo them.
- Make a var_dump() for each relevant value to check the content.
|

February 27th, 2013, 07:05 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
Quote: | Originally Posted by Jacques1 You're talking to a spam bot. See the red "Warnings Level" and "Number of bans" in the top right corner? That's an indicator for spam.
Apart from that, this all doesn't make sense. So $game->name is something like "Alaska Jigsaw", but $db->getEscaped($game->name) suddenly returns the name of the image in the form "games_112921'12"??
Either you're totally mixing up the values, or your code is really, really broken. A database escaping function that magically turns names into file names doesn't work quite ... correctly.
I suggest two things: - Fix your code. Instead of having all kinds of unescaped and escaped values (which overwrite the unescaped attributes), leave the attributes as they are and escape them right before you echo them.
- Make a var_dump() for each relevant value to check the content.
|
First this is not my code, i use from another, and cand make sense in this, onlie little. But problem are that function
PHP Code:
<?php echo $game->name; ?>
write game names, which are ok, but in this part of code
PHP Code:
<img src="<?php echo $game->imgname; ?>" width="100" height="100" alt="<?php echo $game->name; ?>"/><br/>
<?php echo $game->name; ?>
echo part for the name inside alt="" dont show anything. :S Whay this hapen? In one part show ok, in another part do not swow anything. :S
|

February 27th, 2013, 07:30 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
|
I understand your problem, you explained it already.
You have two options: You can keep wondering why this strange behaviour occurs and wait for somebody to come up with the magical explanation -- which will probably never happen. Or you can start investigating the problem.
Like I said, make a var_dump() of $game->name before the HTML stuff. What does the attribute contain? Also try replacing the alt="echo ..." with some hard coded string (echo 'Test' or something like that).
You know, try out different things. That's exactly what we do. We don't have any "magical powers" to find your bugs or something.
|

February 27th, 2013, 07:55 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
|
Can you write exact what i need to do?
Steps by steps. :S My php knowladge are very little. :/
|

February 27th, 2013, 03:38 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
You know the var_dump function, right? I'm saying that you should use it to check the content of your variables. Like this, for example:
This will tell you the exact content of the name attribute, so that we no longer have to speculate about it.
Do that and post the exact output here:
PHP Code:
echo 'Testing: name, namett:<br>';
var_dump($game->name);
var_dump($game->namett);
echo 'end of Testing.<br>';
|

February 27th, 2013, 03:50 PM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
|
string 'MINIBOT XP' (length=10)
Testing: name, namett:
string 'MINIBOT XP' (length=10)
string 'MINIBOT XP' (length=10)
end of Testing.
|

February 27th, 2013, 06:56 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Thanks.
But this clearly shows that namett is not an image name as you claimed earlier. So obviously you're confusing the different variables and attributes. Use namett in the alt attribute, because that's actually the correct (escaped) value.
If it still doesn't work, echo a constant string in the alt attribute:
PHP Code:
alt="<?php echo 'foobar'; ?>"
Does that work?
|

February 28th, 2013, 02:15 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
Quote: | Originally Posted by Jacques1 Thanks.
But this clearly shows that namett is not an image name as you claimed earlier. So obviously you're confusing the different variables and attributes. Use namett in the alt attribute, because that's actually the correct (escaped) value.
If it still doesn't work, echo a constant string in the alt attribute:
PHP Code:
alt="<?php echo 'foobar'; ?>"
Does that work? |
I do not say namett are variables of images name. :S But in alt tag variables namett give name of images, not of game. :S So somthing must be wrong with sytax or something, i tray to find on web, but their in alt tag use another sintax. :S
|

February 28th, 2013, 02:23 AM
|
|
Contributing User
|
|
Join Date: Oct 2012
Location: Croatia
Posts: 66
Time spent in forums: 9 h 58 m 54 sec
Reputation Power: 1
|
|
|
Ovo s foobarom ne radi.
Probao sam to staviti, copy paste. Ne izbacuje mi ništa.Ali kada kopiram izvan img polja, ispiše mi foobar. Znaći mora biti neka zeka s img tagom. :S
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|