MyBB Community Forums

Full Version: MYBB image alt tags?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to find image tags in the post and then: Check if the image has alt="" tag if not then add one! 

It just adds code to all images?

$value = preg_match_all('/<img (.*?)\/>/', $post->data['message']);

                        if(!preg_match('/alt=/', $value))
                        {
                                $post['message'] = str_replace('<img', '<img alt="'.$string.'"', $post['message']);
                         
                        }
http://php.net/manual/en/function.preg-match-all.php

Read the manual to see how preg_match_all works first. preg_match_all() take s athird parameter which is passed by reference for the output matches. I would seriously advise studying PHP properly via the manual or a dedicated PHP tutoring site rather than cobbling things together with various tips and hints that have been posted in support threads such as this.
Thanks but I already did that and couldn't make it work that's why I am asking for support. Could you help me out here?
You could also do this using jQuery.

Might be something like this:
$("img:alt=''");

Haven't tested. http://www.w3schools.com/jquery/jquery_r...ectors.asp
@dragonexpert thanks very much. I am not using jQuery brother could you please help me out with PHP code?
Please read: http://community.mybb.com/thread-154758-...pid1079864

I know I may be a bit annoying, but this forum is for MyBB-related questions and yours should be posted on a PHP-specific board instead most of the times.
@Shade buddy I am trying to replace image alt tag in MYBB post message how come this is not related to MYBB. The regular expression I use returns array error!
Regular expressions are used in PHP, not just MyBB. This is not related to MyBB at all.
not make sense...
parser of mybb is this

<img src=\"{$url}\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"{$alt}\"{$css_align} />"

and

<img src=\"{$url}\" border=\"0\" alt=\"{$alt}\"{$css_align} />

not possible has images without alt...
or you made some modifications that it has interfered.

really this question is not related with mybb...