Skip to content

Commit

Permalink
A combination of a hardened type check, image sources did not show up…
Browse files Browse the repository at this point in the history
… if the option to exclude standard sources from sources lists was selected.
  • Loading branch information
webzunft committed Jan 10, 2024
1 parent 70cdbef commit 9df6a4b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions public/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,12 @@ public function list_post_attachments_with_sources( $post_id = 0 ) {
ISC_Log::log( sprintf( 'going through %d attachments', count( $attachments ) ) );
$atts = [];
foreach ( $attachments as $attachment_id => $attachment_array ) {
$use_standard_source = Standard_Source::use_standard_source( $attachment_id );
$source = self::get_image_source_text( $attachment_id );
$image_uses_standard_source = Standard_Source::use_standard_source( $attachment_id );
$source = self::get_image_source_text( $attachment_id );

// check if source of own images can be displayed
if ( ( $use_standard_source === '' && $source === '' ) || ( $use_standard_source !== '' && $exclude_standard ) ) {
if ( $use_standard_source !== '' && $exclude_standard ) {
if ( ( ! $image_uses_standard_source && $source === '' ) || ( $image_uses_standard_source && $exclude_standard ) ) {
if ( $image_uses_standard_source && $exclude_standard ) {
ISC_Log::log( sprintf( 'image %d: "own" sources are excluded', $attachment_id ) );
} else {
ISC_Log::log( sprintf( 'image %d: skipped because of empty source', $attachment_id ) );
Expand Down Expand Up @@ -644,7 +644,7 @@ public function list_all_post_attachments_sources_shortcode( $atts = [] ) {
$connected_atts[ $_attachment->ID ]['source'] = self::get_image_source_text( $_attachment->ID );
$connected_atts[ $_attachment->ID ]['standard'] = Standard_Source::use_standard_source( $_attachment->ID );
// jump to next element if the standard source is set to be excluded from the source list
if ( Standard_Source::standard_source_is( 'exclude' ) && '' !== $connected_atts[ $_attachment->ID ]['standard'] ) {
if ( Standard_Source::standard_source_is( 'exclude' ) && $connected_atts[ $_attachment->ID ]['standard'] ) {
unset( $connected_atts[ $_attachment->ID ] );
continue;
}
Expand Down

0 comments on commit 9df6a4b

Please sign in to comment.