Create a Pledge: Upload a logo (#45)

* Allow image uploads

* Add the logo as "generated" meta

This will be attached after we've processed the `$_FILES` object into an upload.

* Load image into media library, attach to the submitted pledge as a featured image.

* Move where image handling happens so we can pass back errors

* Pass back error if upload fails

* Create a validation function to do basic checking of form data

* Move logo uploading to a separate function, and rely on core checks for mime & filesize checking

* Tweak function name to be more clear

* Remove bmp, tiff, and ico file types
This commit is contained in:
Kelly Dwan 2019-10-28 11:47:56 -04:00 committed by GitHub
parent 3f774fdb78
commit f9d4a0bd59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 120 additions and 64 deletions

View file

@ -7,7 +7,7 @@ use function WordPressDotOrg\FiveForTheFuture\get_views_path;
/** @var bool $updated */
?>
<form class="pledge-form" id="5ftf-form-pledge-manage" action="" method="post">
<form class="pledge-form" id="5ftf-form-pledge-manage" action="" method="post" enctype="multipart/form-data">
<?php
require get_views_path() . 'inputs-pledge-org-info.php';
require get_views_path() . 'manage-contributors.php';

View file

@ -51,7 +51,7 @@ use function WordPressDotOrg\FiveForTheFuture\get_views_path;
<?php else : ?>
<form class="pledge-form" id="5ftf-form-pledge-new" action="" method="post">
<form class="pledge-form" id="5ftf-form-pledge-new" action="" method="post" enctype="multipart/form-data">
<?php
require get_views_path() . 'inputs-pledge-org-info.php';
require get_views_path() . 'inputs-pledge-contributors.php';

View file

@ -24,7 +24,11 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
<?php esc_html_e( 'Logo', 'wordpressorg' ); ?>
</label>
<br />
<?php /* @todo Display existing logo here */ ?>
<?php if ( is_admin() && has_post_thumbnail() ) : ?>
<div class="form-field__logo-display">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>
<input
type="file"
id="5ftf-org-logo"