使用XML-RPC / functions.php为图像帖子添加alt文本 [英] Add alt text to image posts using XML-RPC/functions.php

查看:148
本文介绍了使用XML-RPC / functions.php为图像帖子添加alt文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下部分代码在我的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代码,带有基于 https://github.com/scottgonzalez/的插件node-wordpress / issues / 43

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文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆