So I just ended up doing a query on the database for the link of the image:
wp db query “SELECT guid FROM wp_posts WHERE ID=’ID_FROM_MEDIA_IMPORT'” –silent –skip-column-names
I wrote this bash script for the whole process:
post-create.sh PATH_TO_IMAGE.FILETYPE “TITLE”
imageID=$(wp media import $1 --porcelain)
imageLINK=$(wp db query "SELECT guid FROM wp_posts WHERE ID='$imageID'" --silent --skip-column-names)
wp post create --post_title="$2" --post_status=publish --post_content="<a href=""$imageLINK""><img class=""size-full"" src=""$imageLINK"" /></a>"
Related Posts:
- Customizing individual images on posts
- Replace image attributes for lazyload plugin (data-src)
- How do I detach images from posts?
- Unattaching images from a post
- How to wrap every image in a post with a div?
- upload featured image from front end using wordpress add media button
- Retrieving and Storing Images Linked from Other Domains on Local Server?
- how to replace embedded “full” sized images within a post with the “large” ones
- Errors when uploading images in WP 3.5
- Remove Featured Image & All Media Uploaded to the Post
- How to allow multiple thumbnail upload for Posts?
- How to get all inline images in post content? [duplicate]
- Inserting Media to WordPress Posts
- Site/Post preview is not working on all social media
- unable to write to the database while uploading images
- Modified core/image rendering not showing in posts – only on pages
- Post images are not displayed in media library
- WordPress Media URLs?
- How would I attach media/images to a post based on a ID stored in a each post’s custom field
- Broken images after importing posts and opening in Gutenberg
- Optimize blog that serves hundred of images and videos
- How to display by default only published posts/pages in the admin area?
- Post/Page Preview Template
- using wp_update_post on save_post
- Post slugs and images cannot have same name?
- WordPress plugin to publish to multiple remote WordPress blogs
- Is there a plugin to make attaching images easier?
- Any way to create a revision of a post ONLY with a new button in the Meta Box?
- Download external images if post is publish
- Can I load posts via Ajax?
- Show One Category on Post
- how to grab first link in post… and of course call it
- WordPress Delete hook with wp_delete_post function?
- Order post by year DESC and month ASC
- How to create post in WP network using WP-CLI
- Do I use custom post type or something else?
- Delete Post From Front-End and attachment permanently
- Limit function to specific post category
- Custom post type permalinks breaking due to 3.1 bug fix
- ‘Invalid post type’ error when importing from one site to another
- How to stop unlink images when remove a site or user
- Blogroll – Different layout for first post
- How to delete old posts’ edits to save space?
- WordPress Theory Lesson – Image Columns within posts with alignment?
- Get image from post’s gallery
- Image Insert into posts and pages not working after 3.2.1 update
- How to display featured image without it appearing in post?
- creating front end image uploader that uploads images as posts
- How to make number of blog posts a custom field?
- WordPress blog or WordPress website
- Using custom post template
- Hiding Draft Post In Admin
- wp_generate_attachment_metadata is creating an empty array
- Editing the default page to show all posts, rather than most recent ones
- List all categories with featured image from post?
- Permission issue with custom post type – not added to menu – by plugin
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- Static posts page with home.php
- Is it possible to customize the post according to post format in single.php?
- Display the 2nd category name of a custom post type without error if its null?
- Querying another post category to match current post and display in loop
- datepicker value in mysql
- How to Featured content with images in home page?
- Simple Custom Metabox Not Saving
- How to show a featured image inside a post in only 1 single category
- How to restore deleted post related with deleted users
- How to get the next and previous image title from attachment or gallery?
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- Custom Post Type Single Loop Outputting Wrong Post
- Can I style single post that are in multiple catergories?
- WordPress Post Deletion Issue
- How Can I Always Display A Particular Post First Using WP_Query?
- MySQL: Possible to replace all of wp_posts.post_content(id#) via UPDATE + REPLACE + SELECT?
- Change modified date to current date when title updated automatically
- Aligning images in the wp editor not working. How do i get this to work in custom theme?
- How to put the author of the post in the comments?
- How to add a custom class attribute into code wrapper? [duplicate]
- Redirecting wordpress search query to archive page
- How to invoke a HTML custom button based on a HTML dropdownlist menu
- Delete attached images from posts
- Schedule image post on download
- The first post appears twice
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- Set featured image on creating new post
- Show Posts By Custom Field
- How to retrieve custom field values and save again as array
- Is there a Standard Format for Clean URLs for Archives of Custom Posts?
- How to get only current images of a post
- Relative Image Urls in Posts are starting from root – Not from WordPress Address (URL) at General Settings
- How to associate media with a post?
- Featured Images link to post parent
- Checking if some condition is matched before inserting post into database
- How do I insert a custom field in a user submitted post?
- Get attachment if matches a variable
- How remove “recent comments” title without modifying code? [closed]
- How edit footer copyright info? [closed]
- Displaying all images from a WordPress post (including media library)
- How to move all images in a post to a single gallery for a bunch of posts?
- WordPress Custom Post type csv exporter
- Edit Page button is gone