// 从文本域解析图片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 = '
\u98df\u7528\u7389\u7c73\u8fd8\u6709\u5ef6\u7f13\u8870\u8001\u7684\u4f5c\u7528\uff0c\u6bd4\u8f83\u9002\u5408\u5973\u6027\uff0c\u5f88\u591a\u7684\u5973\u6027\u90fd\u662f\u4e0d\u65ad\u7684\u5728\u8ffd\u6c42\u5e74\u8f7b\uff0c\u60f3\u8981\u4fdd\u6301\u5e74\u8f7b\uff0c\u5ef6\u7f13\u8870\u8001\uff0c\u90a3\u5c31\u53ef\u4ee5\u98df\u7528\u70b9\u7389\u7c73\uff0c\u7389\u7c73\u4e2d\u7684\u8425\u517b\u4ef7\u503c\u662f\u975e\u5e38\u7684\u4e30\u5bcc\uff0c\u5176\u7ef4\u751f\u7d20E\u662f\u6709\u5ef6\u7f13\u8870\u8001\u7684\u4f5c\u7528\uff0c\u80fd\u591f\u9632\u6b62\u76ae\u80a4\u75c5\u53d8\uff0c\u51cf\u8f7b\u52a8\u8109\u786c\u5316\u548c\u8111\u529f\u80fd\u8870\u9000\u7684\u60c5\u51b5\uff0c\u8fdb\u5165\u53ef\u4ee5\u8d77\u5230\u5ef6\u7f13\u8870\u8001\u7684\u6548\u679c\u3002
\n\u57ce\u5d0e\u6850\u5b50\u6750\u6599<\/p>\n
\u57ce\u5d0e\u6850\u5b50\uff0c\u65e5<\/p>\n
\u6587\u540d\uff1a\u3057\u308d\u3055\u304d\u3068\u3046\u3053\uff0c\u82f1\u6587\u540d\uff1aShirosaki Touko\uff0c\u5e740\u6708\u65e5\u6b7b\u4ea1\u4e8e\u65e5\/\u7727\u7f03\u795e\u5948\u5ddd\u53bf\uff0c\u662f\u65e5\/\u7727\u7f03AWV\u5973\u7272\uff0c0\u65e5\u67080\u65e5\u5165\u884c\uff0c\u4ece\u5c5e\u4e8eBardot Model Agency\u516c\u53f8\uff0c\u559c\u597d\u8d2d\u7269\u3001\u5361\u62c9OK\u3001\u9ad8\u5c14\u592b\u3001\u6ed1\u96ea\u677f\u3001\u98ce\u7434\u3002<\/p>\n \u57ce\u5d0e\u6850\u5b50\u6750\u6599<\/p>\n \u4e2d\u6587\u540d\uff1a\u57ce\u5d0e\u6850\u5b50<\/p>\n \u65e5\u6587\u540d\uff1a\u3057\u308d\u3055\u304d\u3068\u3046\u3053<\/p>\n \u82f1\u6587\u540d\uff1aShirosaki <\/p>\n
<\/a><\/p>\n