Anonymous committed b545296

[svn] deprecate image_tag automatically appending '.png' to sources with no extension
(Sync'd to 4999)

Comments (0)

Files changed (2)


     def test_image_tag(self):
         self.assertEqual('<img alt="Xml" src="/images/xml.png" />',
-                         image_tag('xml'))
+                         image_tag('xml.png'))
         self.assertEqual('<img alt="rss syndication" src="/images/rss.png" />',
-                        image_tag('rss', alt='rss syndication'))
+                        image_tag('rss.png', alt='rss syndication'))
         self.assertEqual('<img alt="Gold" height="70" src="/images/gold.png" width="45" />',
-                         image_tag('gold', size='45x70'))
-        self.assertEqual('<img alt="Symbolize" height="70" src="/images/symbolize.png" width="45" />',
-                         image_tag('symbolize', size='45x70'))
+                         image_tag('gold.png', size='45x70'))
+        self.assertEqual('<img alt="Symbolize" height="70" src="/images/symbolize.jpg" width="45" />',
+                         image_tag('symbolize.jpg', size='45x70'))
         self.assertEqual('<img alt="Pylons-Tower-Dark1" src="" />',


 Provides functionality for linking an HTML page together with other assets, such as
 javascripts, stylesheets, and feeds.
-# Last synced with Rails copy at Revision 4103 on Aug 19th, 2006.
+# Last synced with Rails copy at Revision 4999 on Sep 6th, 2006.
 import os
 import urlparse
+import warnings
 from tags import *
 from routes import request_config
         The source URL of the image. The URL is prepended with '/images/', unless its full
         path is specified. The URL is ultimately prepended with the environment's
         ``SCRIPT_NAME`` (the root path of the web application), unless the URL is
-        fully-fledged (e.g. A source with no filename extension will
-        be automatically appended with the '.png' extension.
+        fully-fledged (e.g.
         The img's alt tag. Defaults to the source's filename, title cased.
-        >>> image_tag('xml')
+        >>> image_tag('xml.png')
         '<img alt="Xml" src="/images/xml.png" />'
-        >>> image_tag('rss', 'rss syndication')
+        >>> image_tag('rss.png', 'rss syndication')
         '<img alt="rss syndication" src="/images/rss.png" />'    
+    if not os.path.splitext(source)[1]:
+        warnings.warn("You've called image_tag with a source that doesn't include an "
+                      "extension. Soon image_tag will no longer automatically append "
+                      "'.png' to your source. Please call image_path('%s.png') instead" % \
+                      source, DeprecationWarning, 2)
     options['src'] = compute_public_path(source, 'images', 'png')
     if not alt:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.