问题描述
我使用以下部分代码在我的wordpress网站上使用 xmlrpc
上传图片:
I am using the following part of code to upload images using xmlrpc
in my wordpress site:
$content = array(
'name' => $title.".".$ext,
'type' => $type,
'bits' => new IXR_Base64(file_get_contents($imgur)),
true
);
$client->query('metaWeblog.newMediaObject', 1, $username, $password, $content);
$media = $client->getResponse();
现在我还想要 alt text
发布了图片发布。我在网上搜索并发现 alt-text
是受保护的元,无法使用 xml-rpc
直接发布。
Now I also want alt text
to be posted with the image post. I searched online and found out that alt-text
is a protected meta and cannot be directly posted using xml-rpc
.
可以通过 xml-rpc进行哪些修改
或有一种方法可以默认使用图片的标题填写 alt-text
发布替代文字
使用 functions.php
?
What modifications can be made to make alt-text
posting possible via xml-rpc
or is there a way to by default fill alt text
with the title of image using functions.php
?
推荐答案
我的解决方案是扩展Wordpress服务器端XMLRPC代码,带有基于
My solution was to extend the Wordpress server-side XMLRPC code with a plugin based on https://github.com/scottgonzalez/node-wordpress/issues/43
一旦你有了一个附件ID,然后通过XMLRPC调用这个方法。
Then call this method via XMLRPC once you have an attachment id.
这篇关于使用XML-RPC / functions.php为图像帖子添加alt文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!