When exporting a content that contains an image, which is wrapped in a link pointing to itself, or another embedded file, either:
- the image is removed or;
- the link disappears.
// Test with img in a link pointing to another file.
|
$input = '<p><a href="@@PLUGINFILE@@' . $filepath . $filenamepdf . '">' .
|
'<img src="@@PLUGINFILE@@' . $filepath . $filenameimg . '"></a></p>';
|
$expected = '<p><a href="files/'. $filenamepdf . '"><img src="files/' . $filenameimg . '"></a></p>';
|
$output = portfolio_rewrite_pluginfile_urls($input, $context->id, $component, $filearea, $itemid, $format, $options);
|
$this->assertSame($expected, $output);
|
|
// Test with img in a link pointing to the image.
|
$input = '<p><a href="@@PLUGINFILE@@' . $filepath . $filenameimg . '">' .
|
'<img src="@@PLUGINFILE@@' . $filepath . $filenameimg . '"></a></p>';
|
$expected = '<p><a href="files/'. $filenameimg . '"><img src="files/' . $filenameimg . '"></a></p>';
|
$output = portfolio_rewrite_pluginfile_urls($input, $context->id, $component, $filearea, $itemid, $format, $options);
|
$this->assertSame($expected, $output);
|
Actually, anything in a link to a file will be stripped out.