-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the specification of alt-text on images when using CLI. #247
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
use bsky_sdk::api; | ||
use bsky_sdk::BskyAgent; | ||
use serde::Serialize; | ||
use std::ffi::OsStr; | ||
use std::path::PathBuf; | ||
use tokio::fs::{create_dir_all, File}; | ||
use tokio::io::AsyncReadExt; | ||
|
@@ -371,10 +370,10 @@ | |
) | ||
.await?, | ||
) | ||
} | ||
Check warning on line 373 in bsky-cli/src/runner.rs GitHub Actions / Rust (1.75.0)
|
||
Command::CreatePost(args) => { | ||
let mut images = Vec::new(); | ||
for image in &args.images { | ||
for (idx,image) in args.images.iter().enumerate() { | ||
if let Ok(mut file) = File::open(image).await { | ||
let mut buf = Vec::new(); | ||
file.read_to_end(&mut buf).await.expect("read image file"); | ||
|
@@ -384,16 +383,23 @@ | |
.com | ||
.atproto | ||
.repo | ||
.upload_blob(buf) | ||
Check warning on line 386 in bsky-cli/src/runner.rs GitHub Actions / Rust (1.75.0)
|
||
.await | ||
.expect("upload blob"); | ||
images.push( | ||
api::app::bsky::embed::images::ImageData { | ||
alt: image | ||
let alt= match args.alt_text.get(idx) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest adding |
||
Some(text) => text.to_owned(), | ||
None => { | ||
image | ||
.file_name() | ||
.map(OsStr::to_string_lossy) | ||
.map(|s| s.to_string_lossy().into_owned()) | ||
.unwrap_or_default() | ||
.into(), | ||
|
||
} | ||
|
||
}; | ||
images.push( | ||
api::app::bsky::embed::images::ImageData { | ||
alt, | ||
aspect_ratio: None, | ||
image: output.data.blob, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is OK to change this to
image
.