Skip to content
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

As A developer I want Documentation on how to upload, create, save and update Media to The Media Library So it's done it as intended #647

Open
chrillep opened this issue Mar 8, 2024 · 1 comment

Comments

@chrillep
Copy link

chrillep commented Mar 8, 2024

First of thanks for a great package! ❤️

  • Corcel Version: 7.0.0
  • Framework Name & Version:
  • PHP Version: 8.3
  • Database Driver & Version:

Description:

There should be documentation on how to

  • upload
  • create
  • save
  • update
    Media to The Media Library

Steps To Reproduce:

@zack-carlson
Copy link

zack-carlson commented Apr 24, 2024

Probably isn't documented because it's outside of the scope of what Corcel does currently, which is read and write to Wordpress Databases using Eloquent.

Attachments are just posts with Post Type = "Attachment", as well as a mime type. The file path is attached via post_meta.

Usually Wordpress does your file upload through normal PHP file upload actions, does some resizing if it's possible then puts it in wp-content/uploads/YYYY/MM/filename.extension

Corcel can only write to the database given it's current configuration. In order to upload media, you'd either need to have the wordpress theme directory as a storage disk in Laravel, or to use the Wordpress API.

I would personally go the API route as there are

  1. already api endpoints for creating media: (https://developer.wordpress.org/rest-api/reference/media/#definition-2)
  2. Already several PHP libraries that consume this API (eg https://github.com/rickwest/laravel-wordpress-api)
  3. Having storage connected to the wp-content folder doesn't "feel" right to me

TLDR

  1. Corcel can't without disk access somehow
  2. Use the API rather than Storage:: facade
  3. Submit a Pull request that creates a new file called Attachment.php in corcel/src/Model/ that extends Post that overrides the create method on Attachcments and does it via the API
    4)???
  4. Profit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants