Is myBB parsing &hash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#11
thanks i give it a shot

BUT how do i do that if the image URL always changes?

i can probably used the php functions to get it done in templates

but the bbcode may be

http://community.mybb.com/thread-175426.html
Reply
#12
Hello!
This is also an answer to your post linked in your last post.
(2015-10-16, 04:53 PM)expat Wrote: so what s happening with this? Do i need a manual change?
what do i need to do to allow the "&" in the myCode?

http://community.mybb.com/thread-185099-...pid1193136
This topic is just for the [url]-Tag when not starting the url with http(s):// , so it has nothing to do with your problem. If you still want to fix it, you have to change
$callback_mycode['url_complex2']['regex'] = "#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#si";
into
$callback_mycode['url_complex2']['regex'] = "#\[url=([^\r\n\"<\(\)]+?)\](.+?)\[/url\]#si";
in /inc/class_parser.php line 309. (remove the &)

I think your problem is located in the script which should serve the images. Have you tried to call the url just in the adressbar?

Best Regards!
Thomas131

Btw: We can help you more, if we have an url of an example. If you like, you can also write me a PM with the link.
Reply
#13
yes, it called to the error image if i paste the link into the address bar

btw, the other way is how to i hack the url parser to leave extensions jpeg|jpg|png|gif alone, and then parse that separately?
Reply
#14
if it didn't work to call the image directly, the error is definitly in the image-handling-script and not in MyBB.

What do you mean "to leave extensions jpeg|jpg|png|gif alone, and then parse that separately?"? The image-Tag-parser searches for [img]-tags and converts them to <img>-Tags (the html-version of [img]). As far as I know, the URL is just copied and isn't changed.
Reply
#15
well, if i put in an IMG URL directly then it will be convert into a URL link....i need it to ignore images....and then parse images independently
Reply
#16
You mean, you enter just an image url, without [img]-Tags and they should be parsed as images? This should be possible, if he correctly detects the image.
Reply
#17
yeah i cannot get this script to work with the hash...so i leave it

BUT i am interested in a IMG parser without using the IMG tag, can you help? adding a width=100% would make responsive
Reply
#18
I have looked after the url-finder-regex and changed some bits. I have just tested the regex on their own and haven't tested them as MyCode. There shouldn't be security-issues with my regex, but maybe there are.

Try to input the followings as MyCode:
(?:[\>\s\(\)]|^)(https?:\/\/[^\/\"\s<>\[\.]+\.(?:[^\/\"\s<>\[\.]+\.)*[\w]+(?::[0-9]+)?(?:\/(?:[^\"\s<>\[]|\[\])*)?(?:[\w\/\)])\.(?:png|jpg|gif|jpeg|bmp))
should be replaced with
<img src="$1" style="width: 100%">
and
(?:[\>\s\(\)]|^)((?:www|ftp)\.(?:[^\/\"\s<>\[\.]+\.)*[\w]+(?::[0-9]+)?(?:\/(?:[^\"\s<\[]|\[\])*)?(?:[\w\/\)])\.(?:png|jpg|gif|jpeg|bmp))
should be replaced with
<img src="//$1" style="width: 100%">
.

I hope that works, I don't have time to debug problems. The Regex itself should work. In the MyCode insert-section in the Admin-CP, there is also an option to controll in which order, the MyCodes are parsed. Maybe you need to tweek there a bit, too.

Best Regards!
Thomas131
Reply
#19
Its a bit more complicated but still possible. Basically you want to make use of the content creation hooks and parse the content. Something like this is a good starting point:

<?php
$content = 'My content http://site.com/image.png?querystring=12 yes, this contains an image';

$imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'bmp'];

foreach (explode(" ", $content) as $word) {
    // strlen($word) is there so that we don't even bother checking short strings
    if (strlen($word) >= 12 && filter_var($word, FILTER_VALIDATE_URL)) {
        foreach ($imageExtensions as $extension) {
            $pos = strpos(strtolower($word), ".".$extension);
            if ($pos) {
                $url = substr($word, $pos+strlen($extension)+1, 1);
                if ($url == '' || $url = '?') {
                    str_replace($word, '[img]'.$word.'[/img]', $content);
                }
            }
        }
    }
}

Make sure to define image extensions in lowercase.
[Image: axolis.png]

Project, Portfolio and Product management for freelancers.
Reply
#20
SentoWebs Solution should work, too, but you will have to make an addon out of this. That isn't complicated for programmers, but it is for just-forum-administrators.
Reply


Forum Jump:


Users browsing this thread: 17 Guest(s)