Simple code to check and update a tag?

Discussion in 'Programming & Software Development' started by Revenger, Jun 22, 2018.

  1. Revenger

    Revenger Member

    Joined:
    Aug 7, 2002
    Messages:
    3,731
    Location:
    Armadale / Perth
    I need to update a image tag with the img_fluid class attribute

    I have this code for my blog listing

    Code:
    <?php
        $query = $db->simple_select('threads', '*', "fid='{$fid}' ORDER BY tid DESC LIMIT {$limit}");
        if($db->num_rows($query) > 0)
        {
            while($row = $db->fetch_array($query))
            {
                $query2 = $db->simple_select('posts', '*', "pid='{$row['firstpost']}'");
                $row2 = $db->fetch_array($query2);
        
                $date = my_date($mybb->settings['dateformat'], $row2['dateline'], "", 1);
                $time = my_date($mybb->settings['timeformat'], $row2['dateline'], "", 1);
    
                $options = array(
                "allow_html" => 1,
                "allow_mycode" => 1,
                "allow_smilies" => 1,
                "allow_imgcode" => 1,
                "allow_videocode" => 1,
                "filter_badwords" => 1
                                );
                $message = $parser->parse_message($row2['message'], $options);
        
    
                $row['threadprefix'] = $rowprefix = '';
                    if($row['prefix'] != 0)
                        {
                            $rowprefix = build_prefixes($row['prefix']);
                            if(!empty($rowprefix))
                        {
                        $row['rowprefix'] = $rowprefix['displaystyle'].'&nbsp;';
                        }
                    }    
              
                echo("<h1><a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['rowprefix']}{$row['subject']}</a></h1>
                    <h2>Posted: {$date} {$time} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a></h2>");
                echo("{$message}");
                echo("<div class=\"replies\">Replies (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)</div>");
                echo("<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\" class=\"btn btn-info btn-sm\" role=\"button\">Read More</a><br><hr>");
            }
        }
        else
        {
            echo 'Nothing to display.';
        }
    
    ?>
    
    I analyzed the output in chrome for the image and see this.
    Code:
    <img src="https://i.imgur.com/S4SpzsM.png" alt="[Image: S4SpzsM.png]" class="mycode_img">
    What I need is where it has "mycode_img" I need it to be "mycode_img img-fluid" so it can also take on the bootstrap fluid element as without it the image as you can see is messed up in placement size.

    Doping it in chrome dev tools works perfect but I know I php add attribute for it that if any tag has the "mycode_img" it translates to "mycode_img img-fluid" as the output.

    Can someone help with what should be a simple fix?
    Did a fix that worked for desktop browsers using the img-fluid css styles but mobile is messed up now and needs fixing as that needs the bootstrap fluid code I image.
     
    Last edited: Jun 22, 2018
  2. neRok

    neRok Member

    Joined:
    Aug 19, 2006
    Messages:
    2,568
    Location:
    Perth NOR
    There doesn't seem to be anything related to images in your code.

    And if you are referring to the images on this page - https://cajgo-support.com/blog.php - they are working fine for me (scaling to suit page). Adding img-fluid doesn't seem to make any difference. There is no functionality for viewing the full-size original image though.
     
  3. OP
    OP
    Revenger

    Revenger Member

    Joined:
    Aug 7, 2002
    Messages:
    3,731
    Location:
    Armadale / Perth
    It's as said the best max width code seemed to take a bit on my phone to work.

    I will eventually look at the fancybox code I use the forums for that blog add I added it manually but I'm no coder so don't know how to make that work with the PHP code.

    I really need someone who knows PHP who can work with me for the remaining features for that page.

    These are still to do for it.

    Pagination
    Image popup
    Anything else that needs doing

    At the moment I need to start sorting through photos from the weekend, I took over 2500 photos of the convention I went too, I'll be processing and showing them on the site, I'll use use some for site branding etc to show the Cosplay side of who we are.

    I hope to get a decent amount of the images that are good quality, I took about 6 photos or so of each person just incase done didn'tdif closeup etc just incase the full doesn't work too well.

    Also recovering as my mouth throat is a bit sore as well as legs a little.

    This will also have a emotional toll on me at some stage as I don't get out much.
     
    Last edited: Jun 25, 2018
  4. neRok

    neRok Member

    Joined:
    Aug 19, 2006
    Messages:
    2,568
    Location:
    Perth NOR
    Instead of popup, just wrap the img in a link, which links to the image, and put target="_blank". That will cause the link to open in a new tab, and that tab will show just the image. Easy!

    Something like this;
    Code:
    <a href="/image1.jpg" target="_blank"><img src="/image1.jpg"></a>
    If you do want a lightbox style popup, a little javascript could target and transform that code easily.
     
  5. OP
    OP
    Revenger

    Revenger Member

    Joined:
    Aug 7, 2002
    Messages:
    3,731
    Location:
    Armadale / Perth
    I think fancybox can turn the image into a link from how I installed it on the forum.

    As it's hooked into the forum I can't exactly be doing stuff that modifies the post.

    I'll look into it when I have tone starting to process the images now
     

Share This Page