Uploading thumbnails
This commit is contained in:
parent
71809eabaa
commit
bb7c80a25c
4 changed files with 19 additions and 17 deletions
|
@ -121,7 +121,7 @@ class LBRY_Daemon
|
||||||
* @param string $language Two letter ISO Code of the language
|
* @param string $language Two letter ISO Code of the language
|
||||||
* @return string $channel The Claim ID of the Channel
|
* @return string $channel The Claim ID of the Channel
|
||||||
*/
|
*/
|
||||||
public function publish($name, $bid, $filepath, $title, $description, $language, $channel)
|
public function publish($name, $bid, $filepath, $title, $description, $language, $channel, $thumbnail = false)
|
||||||
{
|
{
|
||||||
$args = array(
|
$args = array(
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
@ -137,7 +137,10 @@ class LBRY_Daemon
|
||||||
$args['channel_id'] = $channel;
|
$args['channel_id'] = $channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Bring thumbnails into the mix
|
if ($thumbnail) {
|
||||||
|
$args['thumbnail'] = $thumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$result = $this->request(
|
$result = $this->request(
|
||||||
'publish',
|
'publish',
|
||||||
|
|
|
@ -18,7 +18,7 @@ class LBRY_Network_Parser
|
||||||
// COMBAK: Composer is not safe in a wordpress environment. May have to write our own package.
|
// COMBAK: Composer is not safe in a wordpress environment. May have to write our own package.
|
||||||
require_once LBRY_ABSPATH . 'vendor/autoload.php';
|
require_once LBRY_ABSPATH . 'vendor/autoload.php';
|
||||||
$this->converter = new HtmlConverter(array(
|
$this->converter = new HtmlConverter(array(
|
||||||
'strip_tags' => true
|
'strip_tags' => false
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,11 @@ class LBRY_Network_Publisher
|
||||||
$write_status = $file && fwrite($file, $converted);
|
$write_status = $file && fwrite($file, $converted);
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
|
||||||
// TODO: Catch relative exceptions if necessary
|
|
||||||
try {
|
try {
|
||||||
// If everything went well with the conversion, carry on
|
// If everything went well with the conversion, carry on
|
||||||
if ($write_status) {
|
if ($write_status) {
|
||||||
$featured_image = get_the_post_thumbnail($post);
|
$featured_id = get_post_thumbnail_id($post);
|
||||||
|
$featured_image = wp_get_attachment_image_src($featured_id, 'medium');
|
||||||
$name = $post->post_name;
|
$name = $post->post_name;
|
||||||
$bid = floatval(get_option(LBRY_SETTINGS)[LBRY_LBC_PUBLISH]);
|
$bid = floatval(get_option(LBRY_SETTINGS)[LBRY_LBC_PUBLISH]);
|
||||||
$title = $post->post_title;
|
$title = $post->post_title;
|
||||||
|
@ -46,14 +45,15 @@ class LBRY_Network_Publisher
|
||||||
$license = get_option(LBRY_SETTINGS)[LBRY_LICENSE];
|
$license = get_option(LBRY_SETTINGS)[LBRY_LICENSE];
|
||||||
// TODO: See if we can grab from yoast or a default?
|
// TODO: See if we can grab from yoast or a default?
|
||||||
$description = $post->post_title;
|
$description = $post->post_title;
|
||||||
// TODO: Bring thumbnails into the mix
|
$thumbnail = $featured_image[0] ? $featured_image[0] : false;
|
||||||
// $thumbnail = $featured_image ? $featured_image : null;
|
|
||||||
|
|
||||||
LBRY()->daemon->publish($name, $bid, $filepath, $title, $description, $language, $channel);
|
LBRY()->daemon->publish($name, $bid, $filepath, $title, $description, $language, $channel, $thumbnail);
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log('Issue publishing post ' . $post->ID . ' to LBRY: ' . $e->getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
// Delete the temporary markdown file
|
// Delete the temporary markdown file
|
||||||
unlink($filepath);
|
// unlink($filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ class LBRY_Speech
|
||||||
|
|
||||||
if (is_admin()) {
|
if (is_admin()) {
|
||||||
add_action('save_post', array($this, 'upload_media'), 10, 2);
|
add_action('save_post', array($this, 'upload_media'), 10, 2);
|
||||||
} else {
|
}
|
||||||
// Replace the image srcsets
|
// Replace the image srcsets
|
||||||
add_filter('wp_calculate_image_srcset', array($this->parser, 'replace_image_srcset'), 10, 5);
|
add_filter('wp_calculate_image_srcset', array($this->parser, 'replace_image_srcset'), 10, 5);
|
||||||
// Core filter for lots of image source calls
|
// Core filter for lots of image source calls
|
||||||
|
@ -29,7 +29,6 @@ class LBRY_Speech
|
||||||
// Replace any left over urls with speech urls
|
// Replace any left over urls with speech urls
|
||||||
add_filter('the_content', array($this->parser, 'replace_urls_with_speech'));
|
add_filter('the_content', array($this->parser, 'replace_urls_with_speech'));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads assets to the speech server
|
* Uploads assets to the speech server
|
||||||
|
|
Loading…
Reference in a new issue