Skip to content

Commit

Permalink
Merge pull request #159 from xwp/feature/image-details
Browse files Browse the repository at this point in the history
Feature/image details
  • Loading branch information
spacedmonkey committed Jun 12, 2020
2 parents 77b85ad + 4e00da3 commit bfd9c7d
Show file tree
Hide file tree
Showing 14 changed files with 706 additions and 63 deletions.
6 changes: 3 additions & 3 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Unsplash
UNSPLASH_ACCESS_KEY=
UNSPLASH_SECRET_KEY=
UNSPLASH_UTM_SOURCE=
UNSPLASH_ACCESS_KEY=${UNSPLASH_ACCESS_KEY:=}
UNSPLASH_SECRET_KEY=${UNSPLASH_SECRET_KEY:=}
UNSPLASH_UTM_SOURCE=${UNSPLASH_UTM_SOURCE:=}

# MySQL
MYSQL_ROOT_PASSWORD=root
Expand Down
20 changes: 20 additions & 0 deletions assets/src/media-library/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Internal dependencies
*/
import { withUnsplashAttachmentDetails } from './views';

// Override media frames in the media library.
if ( wp.media && wp.media.view ) {
/**
* Override two-column frame in the media library.
*/
if (
wp.media.view.Attachment &&
wp.media.view.Attachment.Details &&
wp.media.view.Attachment.Details.TwoColumn
) {
wp.media.view.Attachment.Details.TwoColumn = withUnsplashAttachmentDetails(
wp.media.view.Attachment.Details.TwoColumn
);
}
}
1 change: 1 addition & 0 deletions assets/src/media-library/views/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as withUnsplashAttachmentDetails } from './with-unsplash-attachment-details';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default View => {
return View.extend( {
// Use the custom Unsplash template.
template: wp.template( 'unsplash-attachment-details-two-column' ),
} );
};
4 changes: 4 additions & 0 deletions assets/src/media-selector/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,7 @@
top: 50px;
}
}

.attachment-info .filename {
font-weight: normal;
}
6 changes: 6 additions & 0 deletions assets/src/media-selector/views/details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const Details = wp.media.view.Attachment.Details.extend( {
className: 'attachment-details unsplash-attachment-details',
template: wp.template( 'unsplash-attachment-details' ),
} );

export default Details;
4 changes: 2 additions & 2 deletions assets/src/media-selector/views/images-browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { ImageViews } from './';
import { ImageViews, Details } from './';
import { getConfig } from '../helpers';

const ImagesBrowser = wp.media.view.AttachmentsBrowser.extend( {
Expand Down Expand Up @@ -89,7 +89,7 @@ const ImagesBrowser = wp.media.view.AttachmentsBrowser.extend( {

sidebar.set(
'details',
new wp.media.view.Attachment.Details( {
new Details( {
controller: this.controller,
model: single,
priority: 80,
Expand Down
1 change: 1 addition & 0 deletions assets/src/media-selector/views/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as Button } from './button';
export { default as Details } from './details';
export { default as ImagesBrowser } from './images-browser';
export { default as ImageView } from './image-view';
export { default as ImageViews } from './image-views';
Expand Down
10 changes: 7 additions & 3 deletions php/class-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ public function process_fields() {
$this->process_data['user'] = $this->get_image_field(
'user',
[
'name' => '',
'id' => '',
'bio' => '',
'name' => '',
'id' => '',
'bio' => '',
'username' => '',
'links' => [
'html' => '',
],
]
);
$this->process_data['file'] = sanitize_title_with_dashes(
Expand Down
Loading

0 comments on commit bfd9c7d

Please sign in to comment.