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

Feature: Include images & captions into export #117

Merged
merged 11 commits into from
Jul 18, 2023

Conversation

bmarshall511
Copy link
Contributor

Description of the Change

New feature to include images & captions in the export file, see #22

Closes #22

How to test the Change

  1. Once there are some blog posts with images & captions, go to Print > Print Issues
  2. Under "Export for InDesign, click "Export All"
  3. Unzip the archive and view the .xml file to ensure the images & captions where exported with the rest of the content

Changelog Entry

Added - New feature to include images & captions in the export

Credits

Props @bmarshall511

Checklist:

@bmarshall511 bmarshall511 requested a review from a team as a code owner June 12, 2023 15:47
@bmarshall511 bmarshall511 requested review from peterwilsoncc and removed request for a team June 12, 2023 15:47
@jeffpaul jeffpaul added this to the 1.3.0 milestone Jun 12, 2023
@bmarshall511 bmarshall511 changed the title Feature/images captions export ben Feature: Include images & captions into export Jun 12, 2023
@bmarshall511
Copy link
Contributor Author

Gonna open a separate PR for the PHP Standards Scrutinizer failures. Getting lots unrelated to these code changes.

@peterwilsoncc
Copy link
Contributor

@bmarshall511 As you'll be opening another PR to address coding standards changes, is it possible to limit this PR to just the functional changes? That will aid with code review and keep the changelog more accurate.

@bmarshall511 bmarshall511 force-pushed the feature/images-captions-export-ben branch from 9caa6f2 to 22b7163 Compare June 13, 2023 11:56
@bmarshall511
Copy link
Contributor Author

@peterwilsoncc No problem! I've reverted back to the functional changes (minus my IDE auto-fixing some of the coding standard issues in the touched files) and merged develop back in. Let me know if that'll work

$this->items[] = $post;
}
}

/**
* Generates content for a single row of the table
*
* @param object $item The current item
* @param object $item The current item
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to be an incorrect PHPCS fix because the line below is incorrect (it has the param name first and the type second and those should be switched)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@@ -260,7 +275,7 @@ function _column_title( $item, $classes = '', $data = '', $primary = false ) {
*/
function column_cb( $item ) {
return '<input type="checkbox" class="article-status" name="article-status[]" value="' .
( isset( $item->ID ) ? absint( $item->ID ) : '' ) . '" />';
( isset( $item->ID ) ? absint( $item->ID ) : '' ) . '" />';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, line 292, 298 and 303, I get these are automated PHPCS fixes but not sure we should even have extra line breaks here to begin with? I'd almost just delete the line break and keep everything on one line, to avoid having extra whitespace show in these inputs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

includes/functions/plugins/article-export.php Show resolved Hide resolved
* Builds the file name for the zip
* Uses the print issue title & day/time
*
* @uses get_timezone
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like this comment is accurate as this method isn't used here but in get_zip_file_name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

'post_status' => __( 'Article Status', 'eight-day-week' ),
);

$title_offset = array_search( 'title', array_keys( $columns ) );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like some extra spacing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


$content = $this->article->post_content;

if ( $post = get_post( get_post_thumbnail_id( $this->id ) ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move the assignment of a variable outside of the if statement:

Suggested change
if ( $post = get_post( get_post_thumbnail_id( $this->id ) ) ) {
$thumbnail = get_post( get_post_thumbnail_id( $this->id ) );
if ( $thumbnail ) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

$content = $this->article->post_content;

if ( $post = get_post( get_post_thumbnail_id( $this->id ) ) ) {
if ( $image = $this->get_image_name( $post->ID ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

}
}

$content = preg_replace_callback(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're doing a number of regex parsing here and this may be fine but parsing HTML using regex can be flaky. May want to consider using something like DOMDocument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines 615 to 616
// return $image ? $this->get_image_tag($image[1], $caption) : '';
return '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, seems like we never return the image since that line is commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a strange one. I was integrating the code from here, but seems like this block is unneeded as gallery images are still exported without it which is being taken care of here.

I've removed that block of code.

Comment on lines 649 to 650
if ( $featured_id = get_post_thumbnail_id( $this->id ) ) {
if ( $image = $this->get_image_name( $featured_id ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above comment on assigning a variable within an if statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@dkotter
Copy link
Collaborator

dkotter commented Jul 7, 2023

I've not tested things out yet but did an initial review. I wouldn't be surprised if most of these are pre-existing issues but seems like a good time to fix those up if we're going to be touching those lines of code anyway. Let me know if there's any questions or concerns on that though.

@jeffpaul
Copy link
Member

Probably good to resolve the items Darin called out here and then any additional ones can be handled in #120

@jeffpaul jeffpaul requested a review from dkotter July 13, 2023 16:05
@bmarshall511
Copy link
Contributor Author

@dkotter I've updated the code based on your comments & reverted the coding standard updates that were unrelated to this issue. Sorry for the confusion, as I got deeper, realized that would be better to move those updates to their own PR due to the massive amount instead on muddying up this one with a bunch of changes unrelated to the functionality of this PR.

With that being said, I'm not super familiar with this plugin or using the exported XML in programs like InDesign, but based on what I'm seeing in the export files, it all seems to be there. In my testing. worked with single images, gallery images & included captions.

Thanks for checking it out! Let me know if there's anything else I need to hit.

@dkotter dkotter merged commit 424b0d2 into develop Jul 18, 2023
@dkotter dkotter deleted the feature/images-captions-export-ben branch July 18, 2023 19:46
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

Successfully merging this pull request may close these issues.

Include images/captions in InDesign export
6 participants