Uploading thumbnails

This commit is contained in:
Paul Kirby 2018-10-31 14:48:58 -05:00
parent 71809eabaa
commit bb7c80a25c
4 changed files with 19 additions and 17 deletions

View file

@ -121,7 +121,7 @@ class LBRY_Daemon
* @param string $language Two letter ISO Code of the language
* @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(
'name' => $name,
@ -137,7 +137,10 @@ class LBRY_Daemon
$args['channel_id'] = $channel;
}
// TODO: Bring thumbnails into the mix
if ($thumbnail) {
$args['thumbnail'] = $thumbnail;
}
try {
$result = $this->request(
'publish',

View file

@ -18,7 +18,7 @@ class LBRY_Network_Parser
// COMBAK: Composer is not safe in a wordpress environment. May have to write our own package.
require_once LBRY_ABSPATH . 'vendor/autoload.php';
$this->converter = new HtmlConverter(array(
'strip_tags' => true
'strip_tags' => false
));
}

View file

@ -33,12 +33,11 @@ class LBRY_Network_Publisher
$write_status = $file && fwrite($file, $converted);
fclose($file);
// TODO: Catch relative exceptions if necessary
try {
// If everything went well with the conversion, carry on
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;
$bid = floatval(get_option(LBRY_SETTINGS)[LBRY_LBC_PUBLISH]);
$title = $post->post_title;
@ -46,14 +45,15 @@ class LBRY_Network_Publisher
$license = get_option(LBRY_SETTINGS)[LBRY_LICENSE];
// TODO: See if we can grab from yoast or a default?
$description = $post->post_title;
// TODO: Bring thumbnails into the mix
// $thumbnail = $featured_image ? $featured_image : null;
$thumbnail = $featured_image[0] ? $featured_image[0] : false;
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 {
// Delete the temporary markdown file
unlink($filepath);
// unlink($filepath);
}
}
}

View file

@ -21,7 +21,7 @@ class LBRY_Speech
if (is_admin()) {
add_action('save_post', array($this, 'upload_media'), 10, 2);
} else {
}
// Replace the image srcsets
add_filter('wp_calculate_image_srcset', array($this->parser, 'replace_image_srcset'), 10, 5);
// Core filter for lots of image source calls
@ -29,7 +29,6 @@ class LBRY_Speech
// Replace any left over urls with speech urls
add_filter('the_content', array($this->parser, 'replace_urls_with_speech'));
}
}
/**
* Uploads assets to the speech server