View Issue Details

IDProjectCategoryView StatusLast Update
4588Composrfiledumppublic2022-08-19 21:42
ReporterChris Graham Assigned ToChris Graham  
PrioritynormalSeverityfeature 
Status resolvedResolutionfixed 
Summary4588: Filedump embed improvements
Description1) Improve performance
2) Allow basic HTML generation as well as Comcode
3) Improve layout a bit

Additional InformationPatch attached.
TagsHas Patch, Roadmap: v11
Attach Tags
Attached Files
filedump_changes.diff (4,080 bytes)   
diff --git a/cms/pages/modules/filedump.php b/cms/pages/modules/filedump.php
index 831c3f12..40cefa50 100644
--- a/cms/pages/modules/filedump.php
+++ b/cms/pages/modules/filedump.php
@@ -928,6 +928,7 @@ class Module_filedump
         ));
 
         $image_sizes = mixed();
+        $is_image = false;
         if (is_saveable_image($file)) {
             $size = @getimagesize($path);
             if ($size !== false) {
@@ -958,6 +959,8 @@ class Module_filedump
                     );
                 }
             }
+
+            $is_image = true;
         }
 
         $_existing_count = find_filedump_links($place . $file);
@@ -976,6 +979,8 @@ class Module_filedump
             'URL' => $url,
             'IMAGE_SIZES' => $image_sizes,
             'EXISTING_COUNT' => strval($existing_count),
+            'DESCRIPTION' => $description,
+            'IMAGE' => $is_image,
         ));
     }
 
diff --git a/sources/media_renderer.php b/sources/media_renderer.php
index f01ecafd..1a22a1f2 100644
--- a/sources/media_renderer.php
+++ b/sources/media_renderer.php
@@ -313,8 +313,12 @@ function _create_media_template_parameters($url, $attributes, $as_admin = false,
         // As this is not necessarily a local file, we need to get the mime-type in the formal way.
         //  If this was an uploaded file (i.e. new file in the JS security context) with a dangerous mime type, it would have been blocked by now.
         require_code('files2');
-        $meta_details = get_webpage_meta_details($_url);
-        $mime_type = $meta_details['t_mime_type'];
+        if (substr($_url, 0, 17) == 'uploads/filedump/') {
+            $mime_type = ''; // Optimisation: Can find directly from file type
+        } else {
+            $meta_details = get_webpage_meta_details($_url);
+            $mime_type = $meta_details['t_mime_type'];
+        }
         if (($mime_type == 'application/octet-stream') || ($mime_type == '')) {
             require_code('mime_types');
             $mime_type = get_mime_type(get_file_extension(isset($attributes['filename']) ? $attributes['filename'] : $url), true);
diff --git a/themes/default/css/filedump.css b/themes/default/css/filedump.css
index 31e6cc06..f088a565 100644
--- a/themes/default/css/filedump.css
+++ b/themes/default/css/filedump.css
@@ -73,18 +73,30 @@
 
 /* Embed screen */
 
+#generated_html {
+	width: 100%;
+}
+
 .filedump_generated {
 	overflow: hidden;
 }
 
 .filedump_generated_comcode {
+	width: 50%;
+	padding-right: 0.5em;
+	{$BETA_CSS_PROPERTY,box-sizing: border-box;}
+}
+
+.filedump_generated_comcode textarea {
+	width: 100%;
 }
 
 .filedump_generated_preview {
-	margin-left: 1em;
+	padding-left: 0.5em;
 	float: right;
 	{$BETA_CSS_PROPERTY,word-wrap: break-word;}
-	max-width: 560px;
+	width: 50%;
+	{$BETA_CSS_PROPERTY,box-sizing: border-box;}
 }
 
 .filedump_image_sizes label {
diff --git a/themes/default/templates/FILEDUMP_EMBED_SCREEN.tpl b/themes/default/templates/FILEDUMP_EMBED_SCREEN.tpl
index 0632d4e9..2d43936e 100644
--- a/themes/default/templates/FILEDUMP_EMBED_SCREEN.tpl
+++ b/themes/default/templates/FILEDUMP_EMBED_SCREEN.tpl
@@ -15,7 +15,7 @@
 			<label for="generated_comcode" class="lonely_label">{!_COMCODE}:</label>
 			<form action="#" method="post" autocomplete="off">
 				<div>
-					<textarea id="generated_comcode" name="generated_comcode" cols="50" rows="10">{GENERATED*}</textarea>
+					<textarea readonly="readonly" id="generated_comcode" name="generated_comcode" cols="50" rows="10" onclick="this.select();">{GENERATED*}</textarea>
 				</div>
 			</form>
 		</div>
@@ -53,6 +53,17 @@
 			{+END}
 		</ul>
 
+		{+START,IF,{IMAGE}}
+			<p class="lonely_label">
+				<abbr title="HyperText Markup Language">HTML</abbr>:
+			</p>
+			<form action="#" method="post" autocomplete="off">
+				<div>
+					<textarea readonly="readonly" id="generated_html" name="generated_html" cols="50" rows="2" onclick="this.select();">{$SET,html,<img alt="{DESCRIPTION*}" src="{URL*}" />}{$GET*,html}</textarea>
+				</div>
+			</form>
+		{+END}
+
 		<h2>{!_COMCODE}</h2>
 	</div>
 {+END}
filedump_changes.diff (4,080 bytes)   
Time estimation (hours)0.5
Sponsorship open

Sponsor

Date Added Member Amount Sponsored

Activities

Issue History

Date Modified Username Field Change
2021-02-09 22:11 Chris Graham New Issue
2021-02-09 22:11 Chris Graham Tag Attached: Roadmap: v12
2021-02-09 22:11 Chris Graham File Added: filedump_changes.diff
2021-02-09 22:11 Chris Graham Time estimation (hours) => 0.5
2021-11-01 20:12 Chris Graham Tag Attached: Has Patch
2022-08-15 16:58 Chris Graham Tag Detached: Roadmap: v12
2022-08-15 16:58 Chris Graham Tag Attached: Roadmap: v11
2022-08-15 20:44 Chris Graham Assigned To => Chris Graham
2022-08-15 20:44 Chris Graham Status Not Assigned => Assigned
2022-08-19 21:42 Chris Graham Status Assigned => Resolved
2022-08-19 21:42 Chris Graham Resolution open => fixed