Skip to content

Instantly share code, notes, and snippets.

@nobodyiscertain
Created August 13, 2014 04:38
Show Gist options
  • Save nobodyiscertain/2d653736ce92878bb7d9 to your computer and use it in GitHub Desktop.
Save nobodyiscertain/2d653736ce92878bb7d9 to your computer and use it in GitHub Desktop.
Fix for Fieldtype_File for Statamic 1.8.2
From 4e2941f885f07e282b07df0725294e4de6ede311 Mon Sep 17 00:00:00 2001
From: James Wagner <james@thisbythem.com>
Date: Tue, 12 Aug 2014 21:37:04 -0700
Subject: [PATCH] Patch for Fieldtype_File
---
_app/core/bundles/file/ft.file.php | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/_app/core/bundles/file/ft.file.php b/_app/core/bundles/file/ft.file.php
index 5c586f9..c579710 100755
--- a/_app/core/bundles/file/ft.file.php
+++ b/_app/core/bundles/file/ft.file.php
@@ -12,22 +12,24 @@ class Fieldtype_File extends Fieldtype
}
if ($this->field_data) {
-
+
+ $file = Path::toAsset($this->field_data);
+
$html = "<div class='file-field-container file-exists'>";
$html .= "<div>";
if (File::isImage(Path::fromAsset($this->field_data, true))) {
- $html .= "<img src='" . Path::toAsset($this->field_data) . "' height='58'>";
+ $html .= "<img src='" . $file . "' height='58'>";
}
$html .= "<p>".basename($this->field_data)."</p>";
$html .= "<a class='btn btn-small btn-remove-file' href='#'>".Localization::fetch('remove')."</a>";
$html .= "</div>";
- $html .= $this->makeFileSelect($this->field_data);
+ $html .= $this->makeFileSelect($file);
} else {
-
+
$html = "<div class='file-field-container'>";
$html .= "<div class='upload-file'>";
$html .= "<p><input type='file' name='{$this->fieldname}' tabindex='{$this->tabindex}' value='' /></p>";
@@ -46,9 +48,9 @@ class Fieldtype_File extends Fieldtype
$html = "<span class='btn btn-file-browse'><span class='ss-icon'>openfolder</span></span>";
$html .= "<p><select name='{$this->fieldname}' style='display:none'>";
$html .= "<option value=''>Select a file...</option>";
-
+
$path = Path::assemble(BASE_PATH, array_get($this->field_config, 'destination'));
-
+
$finder = new Finder();
// Set folder location
@@ -70,7 +72,7 @@ class Fieldtype_File extends Fieldtype
$filename = Path::toAsset($file->getPathname(), false);
$display_name = ltrim(str_replace($path, '', $file->getPathname()), '/');
- $selected = ($this->field_data === $filename) ? 'selected' : '';
+ $selected = ($selected_file === $filename) ? 'selected' : '';
$html .= "<option value='{$filename}' {$selected}>" . $display_name . "</option>";
}
--
1.9.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment