全球主机交流论坛

标题: 大佬推荐个wp远程图片 本地化的插件 [打印本页]

作者: guoaibing    时间: 2019-3-22 23:50
标题: 大佬推荐个wp远程图片 本地化的插件
之前大佬说的QQWorld自动保存图片插件 不知怎么回事用不了

其他的插件都是发布文章才能自动保存的、用火车头远程发布就不行了

大佬推荐个能远程发布的呀
作者: guoaibing    时间: 2019-3-23 00:15
没大佬吗
作者: ihsky    时间: 2019-3-23 00:18
火车头你采回来图片 发布了就行啊
作者: guoaibing    时间: 2019-3-23 00:25
ihsky 发表于 2019-3-23 00:18
火车头你采回来图片 发布了就行啊

火车头采图片要fTP上传应该   不方便呀
作者: ihsky    时间: 2019-3-23 00:35
不用啊 你找个发布模块就行
作者: siyi    时间: 2019-3-23 02:32
我用autopost pro采的,功能没火车头那么强大,关键简单好上手,直接支持远程图片保存到媒体库。



作者: jsjdct    时间: 2019-3-23 04:02
siyi 发表于 2019-3-23 02:32
我用autopost pro采的,功能没火车头那么强大,关键简单好上手,直接支持远程图片保存到媒体库。



你这是开心版吗


作者: njav    时间: 2019-3-23 04:36
siyi 发表于 2019-3-23 02:32
我用autopost pro采的,功能没火车头那么强大,关键简单好上手,直接支持远程图片保存到媒体库。

來個下載連結
作者: yumijie    时间: 2019-3-23 07:02
不要用插件,有纯代码
作者: 312633180    时间: 2019-3-23 09:02
提示: 作者被禁止或删除 内容自动屏蔽
作者: siyi    时间: 2019-3-23 09:12
njav 发表于 2019-3-23 04:36
來個下載連結

链接:https://pan.baidu.com/s/1mC9axzarM6AOFCfcPOUKNg  密码:sx7z
作者: guoaibing    时间: 2019-3-23 09:48
yumijie 发表于 2019-3-23 07:02
不要用插件,有纯代码

用了这段代码  图片确实上传到本地了  内容替换有问题
只有图片路径的后面,域名/wp-content/uploads没加上去

  1. //自动本地化外链图片
  2. add_filter('content_save_pre', 'auto_save_image');
  3. function auto_save_image($content) {
  4. $upload_path = '';
  5. $upload_url_path = get_bloginfo('url');
  6. //上传目录
  7. if (($var = get_option('upload_path')) != '') {
  8. $upload_path = $var;
  9. } else {
  10. $upload_path = 'wp-content/uploads';
  11. }
  12. if (get_option('uploads_use_yearmonth_folders')) {
  13. $upload_path.= '/' . date("Y", time()) . '/' . date("m", time());
  14. }
  15. //文件地址
  16. if (($var = get_option('upload_url_path')) != '') {
  17. $upload_url_path = $var;
  18. } else {
  19. $upload_url_path = get_bloginfo('url');
  20. }
  21. if (get_option('uploads_use_yearmonth_folders')) {
  22. $upload_url_path.= '/wp-content/uploads/' . date("Y", time()) . '/' . date("m", time());
  23. }
  24. require_once ("../wp-includes/class-snoopy.php");
  25. $snoopy_Auto_Save_Image = new Snoopy;
  26. $img = array();
  27. //以文章的标题作为图片的标题
  28. if (!empty($_REQUEST['post_title'])) $post_title = wp_specialchars(stripslashes($_REQUEST['post_title']));
  29. $text = stripslashes($content);
  30. if (get_magic_quotes_gpc()) $text = stripslashes($text);
  31. preg_match_all("/ src=("|\'){0,}(http:\/\/(.+?))("|\'|\s)/is", $text, $img);
  32. $img = array_unique(dhtmlspecialchars($img[2]));
  33. foreach ($img as $key => $value) {
  34. set_time_limit(180); //每个图片最长允许下载时间,秒
  35. if (str_replace(get_bloginfo('url'), "", $value) == $value && str_replace(get_bloginfo('home'), "", $value) == $value) {
  36. //判断是否是本地图片,如果不是,则保存到服务器
  37. $fileext = substr(strrchr($value, '.'), 1);
  38. $fileext = strtolower($fileext);
  39. if ($fileext == "" || strlen($fileext) > 4) $fileext = "jpg";
  40. $savefiletype = array('jpg', 'gif', 'png', 'bmp');
  41. if (in_array($fileext, $savefiletype)) {
  42. if ($snoopy_Auto_Save_Image->fetch($value)) {
  43. $get_file = $snoopy_Auto_Save_Image->results;
  44. } else {
  45. echo "error fetching file: " . $snoopy_Auto_Save_Image->error . "<br>";
  46. echo "error url: " . $value;
  47. die();
  48. }
  49. $filetime = time();
  50. $filepath = "/" . $upload_path; //图片保存的路径目录
  51. !is_dir(".." . $filepath) ? mkdirs(".." . $filepath) : null;
  52. //$filename = date("His",$filetime).random(3);
  53. $filename = substr($value, strrpos($value, '/'), strrpos($value, '.') - strrpos($value, '/'));
  54. //$e = '../'.$filepath.$filename.'.'.$fileext;
  55. //if(!is_file($e)) {
  56. // copy(htmlspecialchars_decode($value),$e);
  57. //}
  58. $fp = @fopen(".." . $filepath . $filename . "." . $fileext, "w");
  59. @fwrite($fp, $get_file);
  60. fclose($fp);
  61. $wp_filetype = wp_check_filetype($filename . "." . $fileext, false);
  62. $type = $wp_filetype['type'];
  63. $post_id = (int)$_POST['temp_ID2'];
  64. $title = $post_title;
  65. $url = $upload_url_path . $filename . "." . $fileext;
  66. $file = $_SERVER['DOCUMENT_ROOT'] . $filepath . $filename . "." . $fileext;
  67. //添加数据库记录
  68. $attachment = array('post_type' => 'attachment', 'post_mime_type' => $type, 'guid' => $url, 'post_parent' => $post_id, 'post_title' => $title, 'post_content' => '',);
  69. $id = wp_insert_attachment($attachment, $file, $post_parent);
  70. $text = str_replace($value, $url, $text); //替换文章里面的图片地址
  71. }
  72. }
  73. }
  74. $content = AddSlashes($text);
  75. remove_filter('content_save_pre', 'auto_save_image');
  76. return $content;
  77. }
  78. function mkdirs($dir) {
  79. if (!is_dir($dir)) {
  80. mkdirs(dirname($dir));
  81. mkdir($dir);
  82. }
  83. return;
  84. }
  85. function dhtmlspecialchars($string) {
  86. if (is_array($string)) {
  87. foreach ($string as $key => $val) {
  88. $string[$key] = dhtmlspecialchars($val);
  89. }
  90. } else {
  91. $string = str_replace('&', '&', $string);
  92. $string = str_replace('"', '"', $string);
  93. $string = str_replace('<', '<', $string);
  94. $string = str_replace('>', '>', $string);
  95. $string = preg_replace('/&(#\d;)/', '&\1', $string);
  96. }
  97. return $string;
  98. }
复制代码

作者: yumijie    时间: 2019-3-23 09:51
guoaibing 发表于 2019-3-23 09:48
用了这段代码  图片确实上传到本地了  内容替换有问题
只有图片路径的后面,域名/wp-content/uploads没加 ...

你是说图片没有保存到本地?还是什么?你说的我看不懂
作者: guoaibing    时间: 2019-3-23 09:51
siyi 发表于 2019-3-23 02:32
我用autopost pro采的,功能没火车头那么强大,关键简单好上手,直接支持远程图片保存到媒体库。

多谢各位大佬  问题是用点skycaiji  只能入库后  在wp里面实现图片本地化啊  真没啥插件了吗
保存到cdn的也行啊
作者: guoaibing    时间: 2019-3-23 09:54
yumijie 发表于 2019-3-23 09:51
你是说图片没有保存到本地?还是什么?你说的我看不懂

图片能保存到本地  就是文章里面  图片地址  不完整  

只有图片地址的后面部分  我改改试试吧 谢大佬了
作者: viccy520    时间: 2019-3-23 10:57
easy-copy-paste   好用的不得鸟。
作者: guoaibing    时间: 2019-3-23 11:21
viccy520 发表于 2019-3-23 10:57
easy-copy-paste   好用的不得鸟。

试过了   远程发布文章不会保存图片。。。
作者: viccy520    时间: 2019-3-23 11:32
guoaibing 发表于 2019-3-23 11:21
试过了   远程发布文章不会保存图片。。。

我用的没问题啊
作者: guoaibing    时间: 2019-3-23 12:42
viccy520 发表于 2019-3-23 11:32
我用的没问题啊

你是编辑器里发布文章应该   

已经解决了skycaiji里面要设置两次才能下载图片。。
作者: guoaibing    时间: 2019-3-23 12:43
感谢各位回复的大佬
作者: viccy520    时间: 2019-3-23 12:57
guoaibing 发表于 2019-3-23 12:42
你是编辑器里发布文章应该   

已经解决了skycaiji里面要设置两次才能下载图片。。 ...

是的
作者: nightmare    时间: 2019-3-23 21:04
一直用qqworld,你看看是不是权限问题
作者: guoaibing    时间: 2019-3-23 22:27
nightmare 发表于 2019-3-23 21:04
一直用qqworld,你看看是不是权限问题

不知道什么情况  、后面那些功能全部点不了、本地环境也试过了



有个站以前用过了这插件就能正常用


作者: 怪人    时间: 2019-3-24 00:54
提示: 作者被禁止或删除 内容自动屏蔽
作者: siyi    时间: 2019-3-24 01:05
怪人 发表于 2019-3-24 00:54
版本号是多少的呢


3.6.1 开心版
作者: playbear    时间: 2019-4-17 16:15
siyi 发表于 2019-3-24 01:05
3.6.1 开心版

地址失效了 能不能补发个?

作者: poko    时间: 2019-4-17 16:17
siyi 发表于 2019-3-23 02:32
我用autopost pro采的,功能没火车头那么强大,关键简单好上手,直接支持远程图片保存到媒体库。


大佬我也在用这个,你的是什么版本,可以分享下吗,我目前的这个版本用不了翻译还不能同时采集多个
作者: 黄师傅    时间: 2019-4-17 16:33
关注啊……
作者: mikj    时间: 2019-4-17 16:47
siyi 发表于 2019-3-23 09:12
链接:https://pan.baidu.com/s/1mC9axzarM6AOFCfcPOUKNg  密码:sx7z

大佬  下载不了
啊哦,你来晚了,分享的文件已经被取消了,下次要早点哟。
作者: siyi    时间: 2019-4-17 16:49
@mikj @poko
我后来还是老老实实用火车头,采集的时候太卡了,小鸡快跑不动了~

链接:https://pan.baidu.com/s/1oVVdCYvFs0mezpW_s5n75Q  密码:zxqj
作者: 方块李    时间: 2019-4-17 16:54
siyi 发表于 2019-3-23 09:12
链接:https://pan.baidu.com/s/1mC9axzarM6AOFCfcPOUKNg  密码:sx7z

求大佬私个链接,没有了
作者: mikj    时间: 2019-4-17 17:02
siyi 发表于 2019-4-17 16:49
@mikj @poko
我后来还是老老实实用火车头,采集的时候太卡了,小鸡快跑不动了~

可以了 大佬 谢谢
作者: yooooo    时间: 2019-4-17 17:15
QQWorld我用的挺好的
作者: poko    时间: 2019-4-17 17:23
siyi 发表于 2019-4-17 16:49
@mikj @poko
我后来还是老老实实用火车头,采集的时候太卡了,小鸡快跑不动了~

这个版本好像就是只能采集一个的,多任务会暂停,不完全版好像。。




欢迎光临 全球主机交流论坛 (https://fd.vvwvv.eu.org/) Powered by Discuz! X3.4