Coder Social home page Coder Social logo

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 about corcel HOT 2 OPEN

chrillep avatar chrillep commented on June 11, 2024
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

from corcel.

Comments (2)

zack-carlson avatar zack-carlson commented on June 11, 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!

from corcel.

chrillep avatar chrillep commented on June 11, 2024

Everything you wrote is correct 😀🙌.

Thanks for talong the time to write ❤️.

It should be well documented 😉.

The is a an attachment Class already.
That's why I wanted this in the first place.

https://github.com/corcel/corcel/blob/8.0/src/Model/Attachment.php

I'll have a 👀 at the referenced package.

from corcel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.