// 从文本域解析图片URL,返回指定数量的不同随机图片URL private function get_random_img_urls( $count = 1 ) { $raw = get_option( self::OPTION_IMG_URLS, '' ); if ( empty( $raw ) ) return array(); $lines = explode( "\n", $raw ); $urls = array(); foreach ( $lines as $line ) { $url = trim( $line ); if ( ! empty( $url ) ) { $urls[] = $url; } } if ( empty( $urls ) ) return array(); // 打乱数组顺序,保证随机性 shuffle( $urls ); // 如果需要的数量大于可用数量,循环补充 $result = array(); $urlCount = count( $urls ); for ( $i = 0; $i < $count; $i++ ) { $result[] = $urls[ $i % $urlCount ]; } return $result; } // 单张随机图兼容方法(保留原有调用) private function get_random_img_url() { $urls = $this->get_random_img_urls( 1 ); return $urls ? $urls[0] : ''; } private function process_post( $post_id, $source ) { $post = get_post( $post_id ); if ( ! $post || 'publish' !== $post->post_status ) return; $content = (string)$post->post_content; $images = $this->extract_image_urls( $content ); // 文章无图片 → 中间插入图片(原有逻辑不变) if ( empty( $images ) ) { $new_img_url = $this->get_random_img_url(); if ( empty( $new_img_url ) ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => '未配置可用图片地址,无法新增图片', 'image_count' => 0, 'broken_count' => 0, 'replaced_count' => 0, 'old_urls' => array(), 'new_urls' => array(), 'run_source' => $source ) ); return; } $img_tag = '

'; $content_len = mb_strlen( $content ); $mid_pos = (int)( $content_len / 2 ); $new_content = mb_substr( $content, 0, $mid_pos ) . $img_tag . mb_substr( $content, $mid_pos ); $updated = wp_update_post( array( 'ID' => $post_id, 'post_content' => $new_content ), true ); if ( is_wp_error( $updated ) ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => '新增图片失败:' . $updated->get_error_message(), 'image_count' => 0, 'broken_count' => 0, 'replaced_count' => 1, 'old_urls' => array(), 'new_urls' => array( $new_img_url ), 'run_source' => $source ) ); return; } clean_post_cache( $post_id ); $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'add_image', 'reason' => '文章无图片,已在内容中间插入图片', 'image_count' => 1, 'broken_count' => 0, 'replaced_count' => 1, 'old_urls' => array(), 'new_urls' => array( $new_img_url ), 'run_source' => $source ) ); return; } // 检测失效图片(原有逻辑不变) $broken_urls = array(); $reasons = array(); foreach ( $images as $url ) { $check = $this->is_image_url_valid( $url ); if ( ! $check['valid'] ) { $broken_urls[] = $url; $reasons[] = $url . ' => ' . $check['reason']; } } $broken_urls = array_values( array_unique( $broken_urls ) ); if ( empty( $broken_urls ) ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'no_need', 'reason' => '所有图片均可正常访问', 'image_count' => count( $images ), 'broken_count' => 0, 'replaced_count' => 0, 'old_urls' => array(), 'new_urls' => array(), 'run_source' => $source ) ); return; } // 替换失效图片(核心修改部分) $new_content = $content; $replace_map = array(); $replaced_count = 0; $failed_reason = ''; // 获取与失效图片数量匹配的随机备用图 $rand_imgs = $this->get_random_img_urls( count( $broken_urls ) ); if ( empty( $rand_imgs ) ) { $failed_reason = '未配置可用图片地址,无法替换'; } else { // 为每个失效URL分配不同的备用图 foreach ( $broken_urls as $index => $bad_url ) { $new_img = $rand_imgs[ $index ]; if ( false !== strpos( $new_content, $bad_url ) ) { $new_content = str_replace( $bad_url, $new_img, $new_content ); $replace_map[ $bad_url ] = $new_img; $replaced_count++; } } } if ( $failed_reason ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => $failed_reason . ';失效明细:' . implode( ';', $reasons ), 'image_count' => count( $images ), 'broken_count' => count( $broken_urls ), 'replaced_count' => $replaced_count, 'old_urls' => $broken_urls, 'new_urls' => $replace_map, 'run_source' => $source ) ); return; } if ( $new_content === $content || $replaced_count <= 0 ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => '检测到失效图片,但未能完成替换;失效明细:' . implode( ';', $reasons ), 'image_count' => count( $images ), 'broken_count' => count( $broken_urls ), 'replaced_count' => 0, 'old_urls' => $broken_urls, 'new_urls' => $replace_map, 'run_source' => $source ) ); return; } $updated = wp_update_post( array( 'ID' => $post_id, 'post_content' => $new_content ), true ); if ( is_wp_error( $updated ) ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => '文章更新失败:' . $updated->get_error_message(), 'image_count' => count( $images ), 'broken_count' => count( $broken_urls ), 'replaced_count' => 0, 'old_urls' => $broken_urls, 'new_urls' => $replace_map, 'run_source' => $source ) ); return; } clean_post_cache( $post_id ); $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'success', 'reason' => '已替换失效图片;失效明细:' . implode( ';', $reasons ), 'image_count' => count( $images ), 'broken_count' => count( $broken_urls ), 'replaced_count' => $replaced_count, 'old_urls' => $broken_urls, 'new_urls' => $replace_map, 'run_source' => $source ) ); } 由于该设备有问题windows已将其停止代码43 usb-番剧百科
好东西要分享

由于该设备有问题windows已将其停止代码43 usb

您好,现在汉格来为大家解答以上的问题。由于该设备有问题windows已将其停止代码43 usb相信很多小伙伴还不知道,现在让我们一起来看看吧!

1、解决方法:win+R打开运行界面。

2、2、在运行窗口中输入gpedit.msc命令,点击确定。

3、3、点击管理模块里的系统4、在系统里点击“驱动程序安装”5、点击第一项6、点击已启用7、点击确定后再点击应用即可拓展资料安装驱动程序时,建议不要直接点setup.exe安装,可以按照如下步骤进行:1.进入“设备管理器”后,右键单击“显示卡”下的显卡名称,然后点击右键菜单中的“属性”。

4、2.进入显卡属性后点击“驱动程序”标签,选择“更新驱动程序”,然后选择“显示已知设备驱动程序的列表,从中选择特定的驱动程序”。

5、3.当弹出驱动列表后,选择“从磁盘安装”。

6、接着点击“浏览”按钮,在弹出的查找窗口中找到驱动程序所在的文件夹,按“打开”按钮,最后确定。

7、4.此时驱动程序列表中出现了许多显示芯片的名称,根据你的显卡类型,选中一款后按“确定”完成安装。

8、如果程序是非WHQL版,则系统会弹出一个警告窗口,不要理睬它,点击“是”继续安装,最后根据系统提示重新启动电脑即可。

9、另外,值得注意的是,显卡驱动安装错误,也有可能是显卡安装不到位引起,因此在安装显卡时,一定要注意显卡金手指要完全插入AGP插槽。

10、 参考资料来源:百度百科:显卡程序。

本文就为大家分享到这里,希望小伙伴们会喜欢。

评论 抢沙发

评论前必须登录!