This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
incorporating some tweaks from Jens Korff and a fix to the issue of a…
…nchoring & going back
- Loading branch information
1 parent
0112445
commit ec793cc
Showing
1 changed file
with
18 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
http://easy-designs.net/ | ||
===================================================== | ||
This extension was created by Aaron Gustafson | ||
- [email protected] | ||
([email protected]) with contributions from | ||
Jens Korff | ||
This work is licensed under the MIT License. | ||
===================================================== | ||
File: pi.easy_jail.php | ||
|
@@ -96,19 +97,24 @@ function prep( $str='', $xhtml='', $class_name='', $blank_img='' ) | |
$instance[2] = substr( $instance[2], 0, -1 ); | ||
} | ||
|
||
foreach ( explode( ' ', trim( $instance[2] ) ) as $attr ) | ||
# Get all attributes | ||
# Reference: http://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php#answer-2937682 | ||
$doc = new DOMDocument(); | ||
@$doc->loadHTML($o_img); | ||
$tags = $doc->getElementsByTagName('img'); | ||
|
||
foreach ( $tags as $tag ) | ||
{ | ||
preg_match_all( '/([^=]*)=([\'"])(.*)\\2$/', $attr, $matches, PREG_SET_ORDER ); | ||
|
||
if ( isset( $matches[0] ) ) | ||
foreach ( $tag->attributes as $attribute ) | ||
{ | ||
if ( $matches[0][1] == 'src' ) | ||
{ | ||
$src = $matches[0][3]; | ||
} | ||
else | ||
$name = $attribute->name; | ||
$value = $attribute->value; | ||
|
||
if ( $name == 'src' ) | ||
{ | ||
$attributes[$matches[0][1]] = $matches[0][1] . '="' . $matches[0][3] . '"'; | ||
$src = $value; | ||
} else { | ||
$attributes[$name] = $name . '="' . $value . '"'; | ||
} | ||
} | ||
} | ||
|
@@ -168,7 +174,7 @@ function js( $class_name='', $config='' ) | |
$js .= file_get_contents( PATH_THIRD . '/easy_jail/vendors/jail/dist/jail.min.js' ) . "\n\n"; | ||
|
||
# build the trigger | ||
$template = '(function($){$("img.{class_name}").jail({jail_config});}(jQuery));'; | ||
$template = '(function(window,$){$("img.{class_name}").jail({jail_config});$(window).on("load",function(){$(this).resize();});}(this,jQuery));'; | ||
$swap = array( | ||
'class_name' => $class_name, | ||
'jail_config' => $config | ||
|