• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item6508: ATTACHEDIMAGEFORMAT issues

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine Attach.pm Normal Closed   patch 5.0.1

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

Attach.pm allows created links to be formatted using the ATTACHIMAGEFORMAT preference variable.

Intended for internationalization, it turns out that it can be useful for other purposes, such as invoking the thumbnail plugin.

The $size string is almost usable as a macro argument - except that it uses single instead of double quotes and the macro parser won't handle this.

--- lib/TWiki/Attach.pm~        2008-09-11 23:41:58.000000000 -0400
+++ lib/TWiki/Attach.pm 2010-06-27 07:00:49.000000000 -0400
@@ -298,11 +298,11 @@
         my( $nx, $ny ) = &_imgsize( $stream, $attName );
         my @attrs;

         if( $nx > 0 && $ny > 0 ) {
             push( @attrs, width=>$nx, height=>$ny );
-            $imgSize = "width='$nx' height='$ny'";
+            $imgSize = "width=\"$nx\" height=\"$ny\"";
         }

         $fileLink = $prefs->getPreferencesValue( 'ATTACHEDIMAGEFORMAT' );
         unless( $fileLink ) {
             push( @attrs, src=>"%ATTACHURLPATH%/$fileURL" );

Also, note that $comment should be expanded after $size; currently a comment containing $size will include width='n' height='m', which probably is not what was intended.

For extra points, implement $width and $height.

For serious points, allow conditional expansion. Here's the actual application (wrapped for display):

* Set ATTACHEDIMAGEFORMAT = \n   * %IF{"$ 'THUMBNAIL_PLUGIN_ENABLE'" 
                                       then="%THUMBVIEW{"$name" $size caption="$comment"}%" 
                                       else="$comment: <br />\n     <img src="%ATTACHURLPATH%/$name" alt="$name" $size />"}%
This puts the entire %IF into the topic text as the link; ideally one would like only the expansion of the %IF (but not the expansion of %ATTACHURLPATH).

-- TWiki:Main/TimotheLitt - 27 Jun 2010

Thank you Timothe for reporting the issue and for providing the patch.

1. The single/double quote issue should go into trunk and 5.0 branch.

2. $comment should be expanded after $size: Yes, should go into trunk and 5.0 branch.

3. Implement $width and $height: Good idea. Should go into trunk and 5.0 branch. Should be documented in TWikiPreferences.

4. THUMBVIEW support: I am not in favor of having IF statement in the topic text for images, because the IMG tag is handled properly by the WYSIWYG editor. For example, you can resize the image. This no longer works if we have the IMG tag hidden in an IF.

I suggest to file an enhancement request for item 4 to have control over variable expansion for the ATTACHEDIMAGEFORMAT setting. Preferably a generic spec that works for other settings too. It is a bit complex because in the ATTACHEDIMAGEFORMAT case we want to have IF expanded, but not THUMBVIEW and ATTACHURLPATH.

Since you have SVN core access, could you commit items 1, 2, 3? Item 4 should be handled as an enhancement request with new TWikibug item.

-- TWiki:Main.PeterThoeny - 28 Jun 2010

[1] and [2] done. I could not test what timotthe suggested, need to install plugin etc. will check this later.

-- TWiki:Main.SopanShewale - 29 Jun 2010

[3] is done too, thanks to patch Timothe sent via e-mail. Thanks Timothe!

Doc update in TWiki.TWikiPreferences is done too. Now in SVN trunk and 5.0 branch.

-- TWiki:Main.PeterThoeny - 30 Jun 2010

ItemTemplate
Summary ATTACHEDIMAGEFORMAT issues
ReportedBy TWiki:Main.TimotheLitt
Codebase 5.0.0, ~twiki4
SVN Range TWiki-5.0.0, Sun, 20 Jun 2010, build 19085
AppliesTo Engine
Component Attach.pm
Priority Normal
CurrentState Closed
WaitingFor

Checkins TWikirev:19159 TWikirev:19160 TWikirev:19162 TWikirev:19163 TWikirev:19164 TWikirev:19165
TargetRelease patch
ReleasedIn 5.0.1
Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2010-10-12 - PeterThoeny
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback