Avifinfo

Features::get_item_features()privateWP 1.0

Binds the width, height, bit depth and number of channels from stored internal features.

Метод класса: Features{}

Хуков нет.

Возвращает

Status. FOUND on success or NOT_FOUND on failure.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_item_features( $target_item_id, $tile_depth );
$target_item_id(int) (обязательный)
Id of the item whose features will be bound.
$tile_depth(int) (обязательный)
Maximum recursion to search within tile-parent relations.

Код Features::get_item_features() WP 6.6.2

private function get_item_features( $target_item_id, $tile_depth ) {
  foreach ( $this->props as $prop ) {
    if ( $prop->item_id != $target_item_id ) {
      continue;
    }

    // Retrieve the width and height of the primary item if not already done.
    if ( $target_item_id == $this->primary_item_id &&
         ( $this->primary_item_features['width'] == UNDEFINED ||
           $this->primary_item_features['height'] == UNDEFINED ) ) {
      foreach ( $this->dim_props as $dim_prop ) {
        if ( $dim_prop->property_index != $prop->property_index ) {
          continue;
        }
        $this->primary_item_features['width']  = $dim_prop->width;
        $this->primary_item_features['height'] = $dim_prop->height;
        if ( $this->primary_item_features['bit_depth'] != UNDEFINED &&
             $this->primary_item_features['num_channels'] != UNDEFINED ) {
          return FOUND;
        }
        break;
      }
    }
    // Retrieve the bit depth and number of channels of the target item if not
    // already done.
    if ( $this->primary_item_features['bit_depth'] == UNDEFINED ||
         $this->primary_item_features['num_channels'] == UNDEFINED ) {
      foreach ( $this->chan_props as $chan_prop ) {
        if ( $chan_prop->property_index != $prop->property_index ) {
          continue;
        }
        $this->primary_item_features['bit_depth']    = $chan_prop->bit_depth;
        $this->primary_item_features['num_channels'] = $chan_prop->num_channels;
        if ( $this->primary_item_features['width'] != UNDEFINED &&
            $this->primary_item_features['height'] != UNDEFINED ) {
          return FOUND;
        }
        break;
      }
    }
  }

  // Check for the bit_depth and num_channels in a tile if not yet found.
  if ( $tile_depth < 3 ) {
    foreach ( $this->tiles as $tile ) {
      if ( $tile->parent_item_id != $target_item_id ) {
        continue;
      }
      $status = $this->get_item_features( $tile->tile_item_id, $tile_depth + 1 );
      if ( $status != NOT_FOUND ) {
        return $status;
      }
    }
  }
  return NOT_FOUND;
}