|
From: <var...@us...> - 2009-01-08 09:46:28
|
Revision: 6379
http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6379&view=rev
Author: vargenau
Date: 2009-01-08 09:46:18 +0000 (Thu, 08 Jan 2009)
Log Message:
-----------
New function is_image
Modified Paths:
--------------
trunk/lib/EditToolbar.php
trunk/lib/stdlib.php
Modified: trunk/lib/EditToolbar.php
===================================================================
--- trunk/lib/EditToolbar.php 2009-01-08 09:40:18 UTC (rev 6378)
+++ trunk/lib/EditToolbar.php 2009-01-08 09:46:18 UTC (rev 6379)
@@ -391,11 +391,8 @@
$image_js = '';
foreach ($images as $image) {
// Select only files ending in ".png", ".gif", ".jpg", ".jpeg"
- if ((string_ends_with($image, ".jpg"))
- or (string_ends_with($image, ".jpeg"))
- or (string_ends_with($image, ".gif"))
- or (string_ends_with($image, ".png"))) {
- $image_js .= ",['$image','{{".$image."}}']";
+ if (is_image($image)) {
+ $image_js .= ",['$image','{{".$image."}}']";
}
}
$image_js = substr($image_js, 1);
Modified: trunk/lib/stdlib.php
===================================================================
--- trunk/lib/stdlib.php 2009-01-08 09:40:18 UTC (rev 6378)
+++ trunk/lib/stdlib.php 2009-01-08 09:46:18 UTC (rev 6379)
@@ -2327,6 +2327,26 @@
return $options;
}
+/**
+ * Returns true if the filename ends with an image suffix.
+ * Uses INLINE_IMAGES if defined, else "png|jpg|jpeg|gif"
+ */
+function is_image ($filename) {
+
+ if (defined('INLINE_IMAGES')) {
+ $inline_images = INLINE_IMAGES;
+ } else {
+ $inline_images = "png|jpg|jpeg|gif";
+ }
+
+ foreach (explode("|", $inline_images) as $suffix) {
+ if (string_ends_with($filename, "." . $suffix)) {
+ return true;
+ }
+ }
+ return false;
+}
+
// (c-file-style: "gnu")
// Local Variables:
// mode: php
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|