1
0
mirror of https://github.com/typemill/typemill.git synced 2025-07-31 11:20:15 +02:00

Version 1.4.7: Option noresize for images

This commit is contained in:
trendschau
2021-07-20 22:45:27 +02:00
parent b3fab62cf4
commit 8d82be9400
7 changed files with 76 additions and 17 deletions

View File

@@ -161,7 +161,17 @@ class MediaApiController extends ContentController
return $response->withJson(['errors' => 'Please check if your media-folder exists and all folders inside are writable.'], 500);
}
if($imageProcessor->publishImage())
# check the resize modifier in the image markdown, set it to true and delete it from markdown
$noresize = false;
$markdown = isset($params['markdown']) ? $params['markdown'] : false;
if($markdown && (strlen($markdown) > 9) && (substr($markdown, -9) == '|noresize') )
{
$noresize = true;
$params['markdown'] = substr($markdown,0,-9);
}
if($imageProcessor->publishImage($noresize))
{
$request = $request->withParsedBody($params);

View File

@@ -48,6 +48,8 @@ class ProcessAssets
$this->fileFolder = $this->mediaFolder . 'files' . DIRECTORY_SEPARATOR;
$this->desiredSizes = $desiredSizes;
ini_set('memory_limit', '1024M');
}
public function checkFolders($forassets = null)

View File

@@ -66,7 +66,7 @@ class ProcessImage extends ProcessAssets
return false;
}
public function publishImage()
public function publishImage($noresize = NULL)
{
# name is stored in temporary folder as name of the .txt-file
foreach(glob($this->tmpFolder . '*.txt') as $imagename)
@@ -97,11 +97,22 @@ class ProcessImage extends ProcessAssets
if($tmpfilename[0] == 'original')
{
if($noresize)
{
$success = copy($this->tmpFolder . $file, $this->liveFolder . $name . '.' . $tmpfilename[1]);
}
$success = rename($this->tmpFolder . $file, $this->originalFolder . $name . '.' . $tmpfilename[1]);
}
if($tmpfilename[0] == 'live')
{
$success = rename($this->tmpFolder . $file, $this->liveFolder . $name . '.' . $tmpfilename[1]);
if($noresize)
{
$success = unlink($this->tmpFolder . $file);
}
else
{
$success = rename($this->tmpFolder . $file, $this->liveFolder . $name . '.' . $tmpfilename[1]);
}
}
if($tmpfilename[0] == 'thumbs')
{

View File

@@ -1589,6 +1589,22 @@ select{
background-color: #eee;
}
/**** special alignment for image checkbox ****/
.control-group.imgcheckmark{
padding-left: 0;
font-size: .9em;
}
.control-group.imgcheckmark input{
width: 0;
margin: 0;
left: 100%;
z-index: 9;
}
.imgcheckmark .checkmark{
left: 100%;
}
/********************
* TOOLTIP *
********************/

View File

@@ -94,6 +94,7 @@ const contentComponent = Vue.component('content-block', {
this.edit = true;
this.unsafed = true;
this.compmarkdown = $event;
console.info(this.compmarkdown);
this.setComponentSize();
},
setComponentSize: function()
@@ -1462,6 +1463,7 @@ const imageComponent = Vue.component('image-component', {
'<label for="imgcaption">{{ \'Caption\'|translate }}: </label><input title="imgcaption" type="text" placeholder="caption" v-model="imgcaption" @input="createmarkdown" max="140" />' +
'<label for="imgurl">{{ \'Link\'|translate }}: </label><input title="imgurl" type="url" placeholder="url" v-model="imglink" @input="createmarkdown" />' +
'<label for="imgclass">{{ \'Class\'|translate }}: </label><select title="imgclass" v-model="imgclass" @change="createmarkdown"><option value="center">{{ \'Center\'|translate }}</option><option value="left">{{ \'Left\'|translate }}</option><option value="right">{{ \'Right\'|translate }}</option></select>' +
'<label v-if="showresize" class="control-group imgcheckmark" for="imgclass">{{ \'Do not resize\'|translate }}:<input title="saveoriginal" class="checkbox" type="checkbox" v-model="noresize" @change="createmarkdown" /><span class="checkmark"></span></label>' +
'<input title="imgid" type="hidden" placeholder="id" v-model="imgid" @input="createmarkdown" max="140" />' +
'</div></div>',
data: function(){
@@ -1479,6 +1481,8 @@ const imageComponent = Vue.component('image-component', {
imgid: '',
imgattr: '',
imgfile: '',
showresize: true,
noresize: false,
}
},
mounted: function(){
@@ -1487,6 +1491,8 @@ const imageComponent = Vue.component('image-component', {
if(this.compmarkdown)
{
this.showresize = false;
this.imgmeta = true;
var imgmarkdown = this.compmarkdown;
@@ -1555,6 +1561,8 @@ const imageComponent = Vue.component('image-component', {
methods: {
openmedialib: function()
{
this.showresize = false;
this.noresize = false;
this.showmedialib = true;
},
isChecked: function(classname)
@@ -1653,6 +1661,11 @@ const imageComponent = Vue.component('image-component', {
errors = 'Maximum size of image caption is 140 characters';
}
}
if(this.noresize === true)
{
imgmarkdown = imgmarkdown + '|noresize';
}
if(errors)
{
@@ -1686,8 +1699,10 @@ const imageComponent = Vue.component('image-component', {
self = this;
self.$parent.freezePage();
self.$root.$data.file = true;
self.load = true;
self.$root.$data.file = true;
self.load = true;
self.showresize = true;
self.noresize = false;
let reader = new FileReader();
reader.readAsDataURL(imageFile);
@@ -1695,14 +1710,16 @@ const imageComponent = Vue.component('image-component', {
self.imgpreview = e.target.result;
myaxios.post('/api/v1/image',{
self.createmarkdown();
myaxios.post('/api/v1/image',{
'url': document.getElementById("path").value,
'image': e.target.result,
'name': imageFile.name,
'csrf_name': document.getElementById("csrf_name").value,
'csrf_value': document.getElementById("csrf_value").value,
})
.then(function (response) {
.then(function (response) {
self.load = false;
self.$parent.activatePage();
@@ -1710,21 +1727,23 @@ const imageComponent = Vue.component('image-component', {
self.imgmeta = true;
self.imgfile = response.data.name;
self.$emit('updatedMarkdown', '![]('+ response.data.name +')');
})
.catch(function (error)
{
/*
})
.catch(function (error)
{
/*
if(httpStatus == 400)
{
self.activatePage();
publishController.errors.message = "Looks like you are logged out. Please login and try again.";
}
*/
if(error.response)
{
publishController.errors.message = error.response.data.errors.message;
}
});
if(error.response)
{
publishController.errors.message = error.response.data.errors.message;
}
});
}
}
}