Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter fdiorazio

    (@fdiorazio)

    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>"

    Thanks for your help, I think I’ll use [gallery options] in some other form in the future.

    Thread Starter fdiorazio

    (@fdiorazio)

    Thanks so much. Although if I don’t use media import on a post ID, then the image ends up at SITEURL/FILENAME which then ends up as a 404, the thumbnail shows, but clicking on it is 404.

    However this is good enough because now I know to use “gallery ids” as post_content and won’t have to fiddle around with dates or paths.

    I played around with “gallery option” and removed the link with “gallery link=”none”” and changed the size, but size wouldn’t change (even with “full”) until I added a column of 1, yet the size was still limited to the page width of the theme, fine for now.

    [gallery ids="298" gallery size="full" gallery link="nonolumns="1"]columns="1"]

Viewing 2 replies - 1 through 2 (of 2 total)