因为每个内容都很少就写到一起了
Typecho本体
修改AliOssForTypecho插件使兼容vditor
其实只要在输出的时候把加一个把空格换成%20的函数就行,改成如下就可以了
就可以解决空格bug
修改Typecho本体使支持webp
Typecho 1.2.0版本
这部分转载自https://chenyu.me/1266.html但这网址我也是常年上不去。
1、找到 Typecho 网站所在文件夹内的以下文件:
var/Widget/Themes/Rows.php
定位到大约第48行的位置,将以下代码:
return preg_match("/screenshot.(jpg|png|gif|bmp|jpeg)/i",path);
修改为:
return preg_match("/screenshot.(jpg|png|gif|bmp|jpeg|webp)/i",path);
2、保存修改后,找到 Typecho 网站所在文件夹下的以下文件:
var/Widget/Base/Contents.php
定位到大概第557行,将以下代码:
$value['attachment']->isImage = in_array($content['type'], ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp']);
修改为:
$value['attachment']->isImage = in_array($content['type'], ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp', 'webp']);
3、保存修改后,再找到 Typecho 网站所在文件夹下的以下文件:
var/Typecho/Common.php
找到图片格式所在的行,大约是在1259行后的位置添加下面这一行代码:
'webp' => 'image/webp',
4、保存修改后,最后进入 Typecho 网站后台,前往 设置 > 基本,在允许上传的文件类型部分,勾选其他格式,并添加webp,然后点击保存设置。
本地
转图片代码
搞不定云端,就只能搞定本地了,能用就行。
#!/bin/bash
while true
do
echo "输入图片地址,支持本地与网络地址,不输入以使用剪切板(仅支持屏幕截图) "
read path
if [[ $path == '' ]];
then
xclip -sel clip -t image/png -o > tmp.png
path="tmp.png"
elif [[ $path == *"http://"* ]] && [[ $path == *"https://"* ]] ;
then
path=$path
# wget "$path" "./tmp.jpg"
else
path=${path//\'/}
fi
# path = "./tmp.jpg"
# path=${path// /}
# path=${path// /-}# 多出来的那个是替换成什么,这个意思是空格替换成-
# echo $path
time=$(date "+%Y-%m-%d-%H-%M-%S")
picinfo=`identify $path`
# arr1=(`echo $picinfo |tr 'x' ' '` )
# readarray -d + -t arr2 <<< "$picinfo"
tmp0=IFS
IFS='+'
read -a arr3 <<< "$picinfo"
IFS=$tmp0
tmp1=${arr3[0]}
readarray -d x -t arr4 <<< "$tmp1"
tmp2=${arr4[1]}
readarray -d ' ' -t arr5 <<< "$tmp2"
width=$((${arr5[0]}))
height=$((${arr5[1]}))
tmp3=1280
if [ $width -gt $tmp3 ] && [ $width -ge $height ];
then
ffmpeg -i "$path" -vf scale=$tmp3:-1 "$time.webp"
inf="width > $tmp3 && width >= height"
echo $inf
elif [ $height -gt $tmp3 ] && [ $height -gt $width ];
then
ffmpeg -i "$path" -vf scale=-1:$tmp3 "$time.webp"
inf="height >$tmp3 && height > width"
echo $inf
else
ffmpeg -i "$path" "$time.webp"
echo "origin"
fi
# xclip -selection clipboard -t image/webp -i "$time.webp"
# if [[ $path=="tmp.png" ]];
# then
# rm tmp.png
# fi
done
#