diff --git a/wire/modules/Process/ProcessPageEditImageSelect/ProcessPageEditImageSelect.module b/wire/modules/Process/ProcessPageEditImageSelect/ProcessPageEditImageSelect.module
index 9a2351f8..6c38055b 100644
--- a/wire/modules/Process/ProcessPageEditImageSelect/ProcessPageEditImageSelect.module
+++ b/wire/modules/Process/ProcessPageEditImageSelect/ProcessPageEditImageSelect.module
@@ -5,7 +5,7 @@
*
* Provides the image selecting and editing capability for rich text editors (TinyMCE/CKEditor)
*
- * ProcessWire 3.x, Copyright 2016 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2018 by Ryan Cramer
* https://processwire.com
*
* @property int $hidpiDefault HiDPI/Retina checkbox default checked?
@@ -32,24 +32,127 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
'permission' => 'page-edit',
);
}
-
- protected $maxImageWidth = 835;
+
+ /**
+ * Max image width when outputting
tags, derives value from $_GET[winwidth]
+ *
+ * @var int
+ *
+ */
+ protected $maxImageWidth = 835;
+
+ /**
+ * Page that the image lives on
+ *
+ * @var Page|null
+ *
+ */
protected $page = null;
+
+ /**
+ * If $page is a repeater item, then $masterPage is the Page the repeater lives on
+ *
+ * @var Page|null
+ *
+ */
protected $masterPage = null;
+
+ /**
+ * The page being edited, if different from $page
+ *
+ * @var Page|null
+ *
+ */
protected $editorPage = null;
- protected $defaultClass = 'Pageimage';
- protected $file = '';
+ //protected $defaultClass = 'Pageimage';
+ //protected $file = '';
+
+ /**
+ * If editing a filename that is a variation, this is the width determined from the filename (123x456)
+ *
+ * @var int
+ *
+ */
protected $editWidth = 0;
+
+ /**
+ * If editing a filename that is a variation, this is the height determined from the filename (123x456)
+ *
+ * @var int
+ *
+ */
protected $editHeight = 0;
+
+ /**
+ * Whether or not HiDPI mode will be used or resizes
+ *
+ * @var bool
+ *
+ */
protected $hidpi = false;
+
+ /**
+ * Extensions to match in a regex for files in $_GET[file]
+ *
+ * @var string
+ *
+ */
protected $extensions = 'jpg|jpeg|gif|png|svg';
+
+ /**
+ * Common translation labels (see init)
+ *
+ * @var array
+ *
+ */
protected $labels = array();
- protected $rte = true; // in RTE mode?
+
+ /**
+ * Are we in Rich Text editor mode? Determined from $_GET[rte]
+ *
+ * @var bool
+ *
+ */
+ protected $rte = true;
+
+ /**
+ * Field of type FieldtypeImage that edited image is part of
+ *
+ * @var Field|null
+ *
+ */
protected $field = null;
+
+ /**
+ * Name of field of type FieldtypeImage that edited image is part of
+ *
+ * @var string
+ *
+ */
protected $fieldName = '';
+
+ /**
+ * If file being edited is a variation, $original is basename of the file it originated from
+ *
+ * @var string
+ *
+ */
protected $original = '';
+
+ /**
+ * Caption text for image when in RTE mode, can be provided in $_GET[caption]
+ *
+ * @var string
+ *
+ */
protected $caption = '';
+ /**
+ * Default module config settings
+ *
+ * @var array
+ *
+ */
protected static $defaultConfig = array(
'hidpiDefault' => 0,
'skipFields' => '',
@@ -144,6 +247,7 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
$fieldName = str_replace($matches[0], '', $fieldName);
} else if(strpos($fieldName, '_LPID')) {
list($fieldName, $lpid) = explode('_LPID', $fieldName);
+ if($lpid) {} // ignore
}
$this->field = $this->wire('fields')->get($fieldName);
if(!$this->field) throw new WireException("Unknown field $fieldName");
@@ -248,8 +352,9 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
$originalFilename = $file;
$file = $this->page->id . ',' . $file;
} else {
- // alrelady has a "123," at beginning
- list($unused, $originalFilename) = explode(',', $file);
+ // already has a "123," at beginning
+ list($pageID, $originalFilename) = explode(',', $file);
+ if($pageID) {} // ignore
}
$originalFilename = $this->wire('sanitizer')->filename($originalFilename, false, 1024);
@@ -422,8 +527,8 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
"&modal=1&id={$this->page->id}&winwidth=$winwidth'>$img";
}
- $class = $this->noThumbs ? "" : " class='thumbs'";
- $out = "\n
";
+ $class = $this->noThumbs ? "" : "thumbs";
+ $out = "\n";
}
@@ -447,6 +552,7 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
$imageFields = $this->getImageFields($this->page);
if(count($imageFields)) {
$imageFieldNames = implode(',', array_keys($imageFields));
+ /** @var InputfieldButton $btn */
$btn = $this->modules->get('InputfieldButton');
$uploadOnlyMode = "$this->page" === "$this->editorPage" ? 1 : 2;
$btn->href = "../edit/?modal=1&id={$this->page->id}&fields=$imageFieldNames&uploadOnlyMode=$uploadOnlyMode";
@@ -622,7 +728,7 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
$crop = $this->processCrop();
$parts = $this->hidpi ? array('width' => $crop->hidpiWidth()) : array();
$this->wire('session')->redirect($this->makeEditURL($crop->basename, $parts));
- return;
+ return '';
} else if($this->wire('input')->post('submit_save_replace')) {
return $this->processSave(true);
} else if($this->wire('input')->post('submit_save_copy')) {
@@ -673,7 +779,7 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
// when RTE mode, go to image selection again when invalid image
$this->error($e->getMessage());
$this->wire('session')->redirect("./?id={$this->page->id}");
- return;
+ return '';
} else {
throw $e;
}
@@ -845,7 +951,7 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
"" .
"" .
"