mirror of
https://github.com/flextype/flextype.git
synced 2025-08-10 07:06:45 +02:00
- update path for media from /image/ to /image/entries/ - update path for media from PATH['entries'] to PATH['assets']
This commit is contained in:
@@ -121,7 +121,7 @@ $flextype['images'] = static function ($container) {
|
||||
|
||||
// Set source filesystem
|
||||
$source = new Filesystem(
|
||||
new Local(PATH['entries'])
|
||||
new Local(PATH['assets'])
|
||||
);
|
||||
|
||||
// Set cache filesystem
|
||||
|
@@ -17,7 +17,7 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
* Generates and returns the image response
|
||||
*/
|
||||
$app->get('/image/{path:.+}', function (Request $request, Response $response, array $args) use ($flextype) {
|
||||
if (Filesystem::has(PATH['entries'] . '/' . $args['path'])) {
|
||||
if (Filesystem::has(PATH['assets'] . '/' . $args['path'])) {
|
||||
return $flextype['images']->getImageResponse($args['path'], $_GET);
|
||||
}
|
||||
|
||||
|
@@ -731,24 +731,6 @@ class EntriesController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getMediaList(string $entry, bool $path = false) : array
|
||||
{
|
||||
$base_url = \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->getBaseUrl();
|
||||
$files = [];
|
||||
foreach (array_diff(scandir(PATH['entries'] . '/' . $entry), ['..', '.']) as $file) {
|
||||
if (strpos($this->registry->get('settings.entries.media.accept_file_types'), $file_ext = substr(strrchr($file, '.'), 1)) !== false) {
|
||||
if (strpos($file, strtolower($file_ext), 1)) {
|
||||
if ($path) {
|
||||
$files[$base_url . '/' . $entry . '/' . $file] = $base_url . '/' . $entry . '/' . $file;
|
||||
} else {
|
||||
$files[$file] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit entry process
|
||||
*
|
||||
@@ -827,7 +809,7 @@ class EntriesController extends Controller
|
||||
$entry_id = $data['entry-id'];
|
||||
$media_id = $data['media-id'];
|
||||
|
||||
$files_directory = PATH['entries'] . '/' . $entry_id . '/' . $media_id;
|
||||
$files_directory = PATH['assets'] . '/entries/' . $entry_id . '/' . $media_id;
|
||||
|
||||
Filesystem::delete($files_directory);
|
||||
|
||||
@@ -850,7 +832,10 @@ class EntriesController extends Controller
|
||||
|
||||
$id = $data['entry-id'];
|
||||
|
||||
$files_directory = PATH['entries'] . '/' . $id . '/';
|
||||
$files_directory = PATH['assets'] . '/entries/' . $id . '/';
|
||||
|
||||
// Create files directory if its not exists
|
||||
! Filesystem::has($files_directory) and Filesystem::createDir($files_directory);
|
||||
|
||||
$file = $this->_uploadFile($_FILES['file'], $files_directory, $this->registry->get('settings.entries.media.accept_file_types'), 27000000);
|
||||
|
||||
@@ -1012,4 +997,23 @@ class EntriesController extends Controller
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getMediaList(string $entry, bool $path = false) : array
|
||||
{
|
||||
$base_url = \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->getBaseUrl();
|
||||
$files = [];
|
||||
foreach (array_diff(scandir(PATH['assets'] . '/entries/' . $entry), ['..', '.']) as $file) {
|
||||
if (strpos($this->registry->get('settings.entries.media.accept_file_types'), $file_ext = substr(strrchr($file, '.'), 1)) !== false) {
|
||||
if (strpos($file, strtolower($file_ext), 1)) {
|
||||
if ($path) {
|
||||
$files[$base_url . '/' . $entry . '/' . $file] = $base_url . '/' . $entry . '/' . $file;
|
||||
} else {
|
||||
$files[$file] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,14 +25,14 @@
|
||||
<div class="item">
|
||||
<a href="javascript:;"
|
||||
{% if (filesystem_ext(file) in ['jpeg', 'png', 'gif', 'jpg']) %}
|
||||
style="background-image: url('{{ base_url() }}/image/{{ id }}/{{ filesystem_basename(file) }}?w=200');"
|
||||
style="background-image: url('{{ base_url() }}/image/entries/{{ id }}/{{ filesystem_basename(file) }}?w=200');"
|
||||
{% else %}
|
||||
style="background: #000;"
|
||||
{% endif %}
|
||||
class="img-item js-entries-image-preview"
|
||||
data-media-id="{{ filesystem_basename(file) }}"
|
||||
data-entry-id="{{ id }}"
|
||||
data-image-url="{{ base_url() }}/image/{{ id }}/{{ filesystem_basename(file) }}">
|
||||
data-image-url="{{ base_url() }}/image/entries/{{ id }}/{{ filesystem_basename(file) }}">
|
||||
<i class="fas fa-eye"></i>
|
||||
{% if (filesystem_ext(file) in ['jpeg', 'png', 'gif', 'jpg']) %}
|
||||
{% else %}
|
||||
|
Reference in New Issue
Block a user