When I embed multiple Sparklines in a single body of content, I only get one image back for all Sparklines. Investigating it some, a pair of braces is missing:

sparkline.module:88
$repl = theme('image', $img);

This is then used on line 90 with the $mtch variable in a str_replace(). Adding braces fixes this problem.

sparkline.module:88
$repl[] = theme('image', $img);

Hope this helps! Looks cool, though. I appreciate this module!

Comments

fractile81’s picture

The line numbers in my bug report should all read 87, not 88. Sorry for the mistake.

fractile81’s picture

Additionally, there's a problem with the RegEx that will keep multiple Sparklines from displaying.

Line 79 reads:

$pattern = "/\[sparkline (.*)\]/";

It needs to read:

$pattern = "/\[sparkline ([^\]]*)\]/";

For those who would like an explanation: The .* in the original RegEx matches all characters, with the \] stopping at the last possible ] in the content, skipping any ] that are not last. This causes text and other Sparklines on the same line to disappear as they are all being included as part of the first Sparkline. The replacement [^\]]* says to match every character EXCEPT a ], allowing the last \] to effectively close the tag when the first ] is encountered after the tag is opened.

Chris Johnson’s picture

Version: master » 4.7.x-1.x-dev
Assigned: Unassigned » Chris Johnson
Status: Active » Fixed

Thanks for the report, and especially thank you for the suggested fixes! I'm sorry I didn't get around to fixing this sooner.

I just applied changes to CVS to put these fixes in.

Anonymous’s picture

Status: Fixed » Closed (fixed)