I'm trying to make images from an external source, provided by a parser
function, work with VisualEditor and Parsoid. For a very simplified
illustration I added the following to the bottom of LocalSettings.php


```
$wgExtensionMessagesFiles['myPfTest'] = "$IP/myPfTest.php";
$wgHooks['ParserFirstCallInit'][] = function( &$parser ) {
    $parser->setFunctionHook(
        'test_func',
        function ( &$parser ) {

            // Output a wiki image and an external image
            $output = "[[File:Test.png|frameless|300px]]" .
                "<br />" .
                "<img src='http://goo.gl/fh3yKh' />";

            return array(
                $output,
                "noparse" => true,
                "isHTML" => true,
            );
        },
        SFH_OBJECT_ARGS
    );
};
$wgAllowExternalImages = false;
$wgAllowImageTag = false;
```


To satisfy the $wgExtensionMessagesFiles requirement, I also added a file
at $IP/myPfTest.php with the contents:


```
<?php

$magicWords = array();
$magicWords['en'] = array(
        'test_func' => array( 0, 'test_func' ),
);
```


When I add a page with wikitext `{{#test_func: }}`, the page displays the
raw wikitext of the File:Test.png and shows the actual image for the
external image. This is as expected.

However, when I click "edit" for Visual Editor, File:Test.png DOES display
(not expected), but the external image does not (also not expected).
Instead the external image displays the raw text "<img src='
http://goo.gl/fh3yKh' />"

Adjusting $wgAllowExternalImages and $wgAllowImageTag to all possible
combinations has no effect. Adjusting "noparse" to true makes File:Test.png
display in view-mode (expected) as well as VE (expected) but has no effect
on the external image. "isHTML" appears to have no effect.

Is there some way to make external images play nicely with VE and/or
Parsoid?

I've tested this on two configurations:

MW 1.25.5
PHP 5.6.14
VE be84313 (head of the REL1_25 branch)
Parsoid ba26a55 (latest commit I've been able to get working with REL1_25)

MW 1.26.2
PHP 5.6.14
VE 34a21d8 (head of the REL1_26 branch)
Parsoid 8976ab9 (latest commit as of a week or so ago, I think)

Thanks,
James
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to