Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLATFORM-4908 Allow to add external image with custom url #21

Open
wants to merge 2 commits into
base: REL1_33_6-FANDOM
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions includes/parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2130,21 +2130,21 @@ private function maybeMakeExternalImage( $url ) {
}

// Fandom change - start (@author ttomalak)
// allow fandom image links PLATFORM-4871
$allowed = Hooks::isRegistered( 'ParserAllowExternalImage' )
&& Hooks::run( 'ParserAllowExternalImage', [ $url ] );
// allow fandom image links PLATFORM-4871 & PLATFORM-4908
$matchExternalImageUrl = $this->siteConfig->has( 'ParserExternalImageUrlRegex' ) ?
preg_match( $this->siteConfig->get( 'ParserExternalImageUrlRegex' ), $url ) :
false;

if ( $this->mOptions->getAllowExternalImages()
|| $allowed
|| ( $imagesexception && $imagematch )
|| ( $imagesexception && $imagematch )
) {
if ( preg_match( self::EXT_IMAGE_REGEX, $url ) || $allowed ) {
if ( $matchExternalImageUrl || preg_match( self::EXT_IMAGE_REGEX, $url ) ) {
# Image found
$text = Linker::makeExternalImage( $url );
}
}
if ( !$text && $this->mOptions->getEnableImageWhitelist()
&& ( preg_match( self::EXT_IMAGE_REGEX, $url ) || $allowed )
&& ( $matchExternalImageUrl || preg_match( self::EXT_IMAGE_REGEX, $url ) )
) {
// Fandom change - end
$whitelist = explode(
Expand Down