Conflict between autolink script and image embedding Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
3 posters

    Conflict between autolink script and image embedding

    avatar
    Soulmonster
    Forumember


    Posts : 228
    Reputation : 2
    Language : Norwegian

    In progress Conflict between autolink script and image embedding

    Post by Soulmonster March 29th 2019, 7:38 pm

    Technical Details


    Forum version : #phpBB3
    Position : Administrator
    Concerned browser(s) : Other
    Who the problem concerns : All members
    When the problem appeared : Some days ago
    Forum link : http://www.a-4-d.com/

    Description of problem

    Hi,

    I have the following script on my forum:

    Code:
    $(function() {
                        var link_words = {
                        };
                        var link_regex = [];
                        for (w in link_words) link_regex.push(w);
                        link_regex = RegExp('\\b(' + link_regex.join('|') + ')\\b(?=\\W)', 'gi');
                for(var i = 0, post = $('.post .content'), p; (p = post[i++]); ) {
                    p.innerHTML = p.innerHTML.replace(link_regex, function (m) {
                    return '<a class="post-word-link" href="' + link_words[m.toLowerCase()] + '">' + m + '</a>';
                    });
                }
            });

    What it does it to automatically create links of words or expression to webpages as defined in the database. It is quite neat, it means that whenever a post is created containing a specific word or expression, that word or expression is automatically made into a link that directs readers to another webpage when clicked.

    This script has worked well for a few years now, expect if any of the keywords are found in an image link, then the link is broken.

    Recently, whenever starting a thread where the thread title contains a keyword, any embedding of images fails. Even if the image link does not contain the keyword, if the keyword is found in the thread title, the image link is broke and the image is not displayed.

    What is happening?
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51520
    Reputation : 3523
    Language : English
    Location : United States

    In progress Re: Conflict between autolink script and image embedding

    Post by SLGray March 29th 2019, 8:16 pm

    Is there an smiley in the topic's title?



    Conflict between autolink script and image embedding Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Soulmonster
    Forumember


    Posts : 228
    Reputation : 2
    Language : Norwegian

    In progress Re: Conflict between autolink script and image embedding

    Post by Soulmonster March 30th 2019, 7:54 am

    SLGray wrote:Is there an smiley in the topic's title?

    No, there are no smileys in the title.

    Here is an example of what happens: http://www.a-4-d.com/t3811-1992-09-dd-rip-it-up-slash#14057

    The thread title contains the word "slash" which is one of the keywords in the autolink script. The first post is supposed to show an image and nothing else (it literally just contains the following image link https://tinyurl.com/y65lory), but instead I see this:

    Conflict between autolink script and image embedding Uten_n10
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15350
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    In progress Re: Conflict between autolink script and image embedding

    Post by skouliki March 30th 2019, 9:44 am

    hello

    try to upload the image with servimg using our editor button
    also the image url is broken https://tinyurl.com/y65lory redirects to Error: Unable to find URL to redirect to....

    avatar
    Soulmonster
    Forumember


    Posts : 228
    Reputation : 2
    Language : Norwegian

    In progress Re: Conflict between autolink script and image embedding

    Post by Soulmonster March 30th 2019, 7:58 pm

    skouliki wrote:hello

    try to upload the image with servimg using our editor button
    also the image url is broken https://tinyurl.com/y65lory redirects to Error: Unable to find URL to redirect to....

    I have realized that the image is not shown when using Edge as the browser, but that it does show with Chrome but that parts of the link is visible underneath the image:

    Conflict between autolink script and image embedding OklCJqb6STSEw7Ts3Xgb+Clipboard01

    Here is the correct image url, btw: https://tinyurl.com/y65loryt

    I disable my filepicker script for uploading images and used the servimg that is default at Forumotion, but it made no difference: http://www.a-4-d.com/t3811-1992-09-dd-rip-it-up-slash#14072
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15350
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    In progress Re: Conflict between autolink script and image embedding

    Post by skouliki March 30th 2019, 8:16 pm

    I use chrome but i can not see the image cause [You must be registered and logged in to see this image.]

    avatar
    Soulmonster
    Forumember


    Posts : 228
    Reputation : 2
    Language : Norwegian

    In progress Re: Conflict between autolink script and image embedding

    Post by Soulmonster March 30th 2019, 8:29 pm

    skouliki wrote:I use chrome but i can not see the image cause [You must be registered and logged in to see this image.]

    Okay. But if you were to register and watch it in chrome, you would see the image but with parts of the link beneath (as shown in my previous post). It is some kind of conflict with my autolink script (from my first post in this thread), and it started happening just a few days ago.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51520
    Reputation : 3523
    Language : English
    Location : United States

    In progress Re: Conflict between autolink script and image embedding

    Post by SLGray March 30th 2019, 9:00 pm

    What happens if you remove the keyword from the topic title?



    Conflict between autolink script and image embedding Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Soulmonster
    Forumember


    Posts : 228
    Reputation : 2
    Language : Norwegian

    In progress Re: Conflict between autolink script and image embedding

    Post by Soulmonster March 30th 2019, 9:02 pm

    SLGray wrote:What happens if you remove the keyword from the topic title?

    Good question. Just did it (changed 'Slash' to 'Slaash'), and now the image is shown perfectly.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51520
    Reputation : 3523
    Language : English
    Location : United States

    In progress Re: Conflict between autolink script and image embedding

    Post by SLGray March 30th 2019, 9:03 pm

    Can you ask for help from where you got the odes?



    Conflict between autolink script and image embedding Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Soulmonster
    Forumember


    Posts : 228
    Reputation : 2
    Language : Norwegian

    In progress Re: Conflict between autolink script and image embedding

    Post by Soulmonster March 30th 2019, 9:10 pm

    SLGray wrote:Can you ask for help from where you got the odes?

    That would be a good idea, but the guy who wrote the code seems to have deleted his site and I don't know how to contact him.

    What the script does is to automatically convert any word in a post that is found in a database, into a link. It is highly useful on my site and I would hate to have to disable to script for good.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51520
    Reputation : 3523
    Language : English
    Location : United States

    In progress Re: Conflict between autolink script and image embedding

    Post by SLGray March 30th 2019, 9:17 pm

    Where is the database?



    Conflict between autolink script and image embedding Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Soulmonster
    Forumember


    Posts : 228
    Reputation : 2
    Language : Norwegian

    In progress Re: Conflict between autolink script and image embedding

    Post by Soulmonster March 30th 2019, 9:19 pm

    SLGray wrote:Where is the database?

    It is actually found within the script itself, but I removed it when I pasted the script into the first post so it wouldn't be so long. It goes in here:

    Code:
     var link_words = {
                        };

    Between { and }.

    here is the full script:

    Code:
    $(function() {
                        var link_words = {

    '14 years' : 'http://www.a-4-d.com/t121-14-years',
    'aint it fun' : 'http://www.a-4-d.com/t164-ain-t-it-fun',
    "ain't it fun" : 'http://www.a-4-d.com/t164-ain-t-it-fun',
    'anything goes' : 'http://www.a-4-d.com/t82-anything-goes',
    'attitude' : 'http://www.a-4-d.com/t170-attitude',
    'axl' : 'http://www.a-4-d.com/t90-axl-rose',
    'back off [Language]' : 'http://www.a-4-d.com/t111-back-off-[Language]',
    'bob' : 'http://www.a-4-d.com/t111-back-off-[Language]',
    'bad apples' : 'http://www.a-4-d.com/t118-bad-apples',
    'bad obsession' : 'http://www.a-4-d.com/t110-bad-obsession',
    'better' : 'http://www.a-4-d.com/t193-better',
    'black hole sun' : '/t2823-black-hole-sun-soundgarden-cover',
    'black leather' : 'http://www.a-4-d.com/t171-black-leather',
    'brain' : 'http://www.a-4-d.com/t154-brain',
    'breakdown' : 'http://www.a-4-d.com/t128-breakdown',
    'buckethead' : 'http://www.a-4-d.com/t148-buckethead',
    'buick makane' : 'http://www.a-4-d.com/t165-buick-makane-big-dumb-sex',
    'bumblefoot' : 'http://www.a-4-d.com/t226-bumblefoot',
    'bumbles' : 'http://www.a-4-d.com/t226-bumblefoot',
    'bumble' : 'http://www.a-4-d.com/t226-bumblefoot',
    'ron' : 'http://www.a-4-d.com/t226-bumblefoot',
    'catcher' : 'http://www.a-4-d.com/t155-catcher-in-the-rye',
    'citr' : 'http://www.a-4-d.com/t155-catcher-in-the-rye',
    'chinese democracy' : 'http://www.a-4-d.com/t177-chinese-democracy',
    'pitman' : 'http://www.a-4-d.com/t203-chris-pitman',
    'mothergoose' : 'http://www.a-4-d.com/t203-chris-pitman',
    'civil war' : 'http://www.a-4-d.com/t120-civil-war',
    'coma' : 'http://www.a-4-d.com/t100-coma',
    'crash diet' : 'http://www.a-4-d.com/t463-crash-diet',
    'dead horse' : 'http://www.a-4-d.com/t119-dead-horse',
    'dizzy' : 'http://www.a-4-d.com/t106-dizzy-reed',
    'dj' : 'http://www.a-4-d.com/t204-dj-ashba',
    "don't cry": 'http://www.a-4-d.com/t105-don-t-cry',
    "double talkin' jive": 'http://www.a-4-d.com/t112-double-talkin-jive',


    'duff' : 'http://www.a-4-d.com/t93-duff-mckagan',

    'estranged' : 'http://www.a-4-d.com/t131-estranged',

    'frank' : 'http://www.a-4-d.com/t223-frank-ferrer',
    'gilby' : 'http://www.a-4-d.com/t98-gilby-clarke',

    "if the world" : 'http://www.a-4-d.com/t190-if-the-world',
    "it's so easy" : 'http://www.a-4-d.com/t73-it-s-so-easy',
    'ise' : 'http://www.a-4-d.com/t73-it-s-so-easy',

    'izzy' : 'http://www.a-4-d.com/t89-izzy-stradlin',
    'josh freese' : 'http://www.a-4-d.com/t225-josh-freese',

    "knockin' on heaven's door" : 'http://www.a-4-d.com/t123-knockin-on-heaven-s-door',
    "knockin on heaven's door" : 'http://www.a-4-d.com/t123-knockin-on-heaven-s-door',
    "knockin' on heavens door" : 'http://www.a-4-d.com/t123-knockin-on-heaven-s-door',
    "knockin on heavens door" : 'http://www.a-4-d.com/t123-knockin-on-heaven-s-door',
    "kohd" : 'http://www.a-4-d.com/t123-knockin-on-heaven-s-door',

    'live and let die' : 'http://www.a-4-d.com/t103-live-and-let-die',
    'lald' : 'http://www.a-4-d.com/t103-live-and-let-die',

    'madagascar' : 'http://www.a-4-d.com/t196-madagascar',
    'matt' : 'http://www.a-4-d.com/t133-matt-sorum',
    'matt sorum' : 'http://www.a-4-d.com/t133-matt-sorum',
    'melissa' : '/t2633-melissa-reese',

    'mr. brownstone' : 'http://www.a-4-d.com/t76-mr-brownstone',
    'mr brownstone' : 'http://www.a-4-d.com/t76-mr-brownstone',

    'my michelle' : '/t78-my-michelle',

    'new rose' : '/t144-new-rose',
    'nice boys' : 'http://www.a-4-d.com/t85-nice-boys',

    'nightrain' : 'http://www.a-4-d.com/t74-nightrain',

    'november rain' : 'http://www.a-4-d.com/t113-november-rain',
    'nr' : 'http://www.a-4-d.com/t113-november-rain',

    'out ta get me' : '/t75-out-ta-get-me',

    'paradise city' : 'http://www.a-4-d.com/t77-paradise-city',
    'pc' : 'http://www.a-4-d.com/t77-paradise-city',

    'patience' : 'http://www.a-4-d.com/t88-patience',

    'paul tobias' : 'http://www.a-4-d.com/t140-paul-tobias',
    'paul huge' : 'http://www.a-4-d.com/t140-paul-tobias',
    'robin' : 'http://www.a-4-d.com/t141-robin-finck',

    'riff raff' : '/t2514-riff-raff',
    'rocket queen' : 'http://www.a-4-d.com/t83-rocket-queen',
    'rq' : 'http://www.a-4-d.com/t83-rocket-queen',

    'richard' : 'http://www.a-4-d.com/t147-richard-fortus',
    '4tus' : 'http://www.a-4-d.com/t147-richard-fortus',
    'slash' : 'http://www.a-4-d.com/t95-slash',
    'saul hudson' : 'http://www.a-4-d.com/t95-slash',
    "shackler's revenge" : 'http://www.a-4-d.com/t153-shackler-s-revenge',
    'sorry' : 'http://www.a-4-d.com/t159-sorry',
    'steven' : 'http://www.a-4-d.com/t91-steven-adler',
    'street of dreams' : 'http://www.a-4-d.com/t157-street-of-dreams',

    "sweet child o' mine" : 'http://www.a-4-d.com/t80-sweet-child-o-mine',
    "sweet child o mine" : 'http://www.a-4-d.com/t80-sweet-child-o-mine',
    "sweet child o'mine" : 'http://www.a-4-d.com/t80-sweet-child-o-mine',
    "scom" : 'http://www.a-4-d.com/t80-sweet-child-o-mine',

    'the seeker' : '/t2512-the-seeker',
    'this i love' : 'http://www.a-4-d.com/t158-this-i-love',
    'til' : 'http://www.a-4-d.com/t158-this-i-love',

    'tommy' : 'http://www.a-4-d.com/t146-tommy-stinson',
    'tracii' : 'http://www.a-4-d.com/t92-tracii-guns',

    'used to love her' : 'http://www.a-4-d.com/t94-used-to-love-her',
    'utlh' : 'http://www.a-4-d.com/t94-used-to-love-her',

    'welcome to the jungle' : 'http://www.a-4-d.com/t72-welcome-to-the-jungle',

    'whole lotta rosie' : '/t124-whole-lotta-rosie',

    'wttj' : 'http://www.a-4-d.com/t72-welcome-to-the-jungle',

    'west arkeen' : 'http://www.a-4-d.com/t107-west-arkeen',

    'yesterdays' : '/t122-yesterdays',
    "you can't put your arms around a memory" : '/t172-you-can-t-put-your-arms-around-a-memory',
    'you could be mine' : 'http://www.a-4-d.com/t114-you-could-be-mine',
    'ycbm' : 'http://www.a-4-d.com/t114-you-could-be-mine'

                        };
                        var link_regex = [];
                        for (w in link_words) link_regex.push(w);
                        link_regex = RegExp('\\b(' + link_regex.join('|') + ')\\b(?=\\W)', 'gi');
                for(var i = 0, post = $('.post .content'), p; (p = post[i++]); ) {
                    p.innerHTML = p.innerHTML.replace(link_regex, function (m) {
                    return '<a class="post-word-link" href="' + link_words[m.toLowerCase()] + '">' + m + '</a>';
                    });
                }
            });
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51520
    Reputation : 3523
    Language : English
    Location : United States

    In progress Re: Conflict between autolink script and image embedding

    Post by SLGray March 30th 2019, 9:50 pm

    I would let others who have more knowledge about coding see if there is any solution.



    Conflict between autolink script and image embedding Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Soulmonster
    Forumember


    Posts : 228
    Reputation : 2
    Language : Norwegian

    In progress Re: Conflict between autolink script and image embedding

    Post by Soulmonster March 31st 2019, 8:07 am

    SLGray wrote:I would let others who have more knowledge about coding see if there is any solution.

    As in hoping that some other members here will chime in with suggestions, or as in asking at another forum more dedicated to JavaScripts and regex coding? If the latter, do you have any suggestions because I am a complete newbie to programming myself.
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15350
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    In progress Re: Conflict between autolink script and image embedding

    Post by skouliki March 31st 2019, 11:02 am

    wait here for other members to reply and help