Submit
Path:
~
/
home
/
bfxleof
/
www
/
wp-content
/
plugins
/
wordpress-seo
/
src
/
helpers
/
schema
/
File Content:
image-helper.php
<?php namespace Yoast\WP\SEO\Helpers\Schema; use Yoast\WP\SEO\Helpers\Image_Helper as Main_Image_Helper; /** * Class Image_Helper. */ class Image_Helper { /** * The HTML helper. * * @var HTML_Helper */ private $html; /** * The language helper. * * @var Language_Helper */ private $language; /** * Represents the main image helper. * * @var Main_Image_Helper */ private $image; /** * Image_Helper constructor. * * @codeCoverageIgnore It handles dependencies. * * @param HTML_Helper $html The HTML helper. * @param Language_Helper $language The language helper. * @param Main_Image_Helper $image The 'main' image helper. */ public function __construct( HTML_Helper $html, Language_Helper $language, Main_Image_Helper $image ) { $this->html = $html; $this->language = $language; $this->image = $image; } /** * Find an image based on its URL and generate a Schema object for it. * * @param string $schema_id The `@id` to use for the returned image. * @param string $url The image URL to base our object on. * @param string $caption An optional caption. * * @return array Schema ImageObject array. */ public function generate_from_url( $schema_id, $url, $caption = '' ) { $attachment_id = $this->image->get_attachment_by_url( $url ); if ( $attachment_id > 0 ) { return $this->generate_from_attachment_id( $schema_id, $attachment_id, $caption ); } return $this->simple_image_object( $schema_id, $url, $caption ); } /** * Retrieve data about an image from the database and use it to generate a Schema object. * * @param string $schema_id The `@id` to use for the returned image. * @param int $attachment_id The attachment to retrieve data from. * @param string $caption The caption string, if there is one. * * @return array Schema ImageObject array. */ public function generate_from_attachment_id( $schema_id, $attachment_id, $caption = '' ) { $data = $this->generate_object( $schema_id ); $data['url'] = $this->image->get_attachment_image_url( $attachment_id, 'full' ); $data['contentUrl'] = $data['url']; $data = $this->add_image_size( $data, $attachment_id ); $data = $this->add_caption( $data, $attachment_id, $caption ); return $data; } /** * Retrieve data about an image from the database and use it to generate a Schema object. * * @param string $schema_id The `@id` to use for the returned image. * @param array $attachment_meta The attachment metadata. * @param string $caption The caption string, if there is one. * * @return array Schema ImageObject array. */ public function generate_from_attachment_meta( $schema_id, $attachment_meta, $caption = '' ) { $data = $this->generate_object( $schema_id ); $data['url'] = $attachment_meta['url']; $data['contentUrl'] = $data['url']; $data['width'] = $attachment_meta['width']; $data['height'] = $attachment_meta['height']; if ( ! empty( $caption ) ) { $data['caption'] = $this->html->smart_strip_tags( $caption ); } return $data; } /** * If we can't find $url in our database, we output a simple ImageObject. * * @param string $schema_id The `@id` to use for the returned image. * @param string $url The image URL. * @param string $caption A caption, if set. * * @return array Schema ImageObject array. */ public function simple_image_object( $schema_id, $url, $caption = '' ) { $data = $this->generate_object( $schema_id ); $data['url'] = $url; $data['contentUrl'] = $url; if ( ! empty( $caption ) ) { $data['caption'] = $this->html->smart_strip_tags( $caption ); } return $data; } /** * Retrieves an image's caption if set, or uses the alt tag if that's set. * * @param array $data An ImageObject Schema array. * @param int $attachment_id Attachment ID. * @param string $caption The caption string, if there is one. * * @return array An imageObject with width and height set if available. */ private function add_caption( $data, $attachment_id, $caption = '' ) { if ( $caption !== '' ) { $data['caption'] = $caption; return $data; } $caption = $this->image->get_caption( $attachment_id ); if ( ! empty( $caption ) ) { $data['caption'] = $this->html->smart_strip_tags( $caption ); return $data; } return $data; } /** * Generates our bare bone ImageObject. * * @param string $schema_id The `@id` to use for the returned image. * * @return array an empty ImageObject */ private function generate_object( $schema_id ) { $data = [ '@type' => 'ImageObject', '@id' => $schema_id, ]; $data = $this->language->add_piece_language( $data ); return $data; } /** * Adds image's width and height. * * @param array $data An ImageObject Schema array. * @param int $attachment_id Attachment ID. * * @return array An imageObject with width and height set if available. */ private function add_image_size( $data, $attachment_id ) { $image_meta = $this->image->get_metadata( $attachment_id ); if ( empty( $image_meta['width'] ) || empty( $image_meta['height'] ) ) { return $data; } $data['width'] = $image_meta['width']; $data['height'] = $image_meta['height']; return $data; } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
.DS_Store
10234 bytes
0644
20200616130143_ReplacePermalinkHashIndex.php
2293 bytes
0644
AjaxController.php
2162 bytes
0644
DownloadConfController.php
945 bytes
0644
JsonSerializable.php
577 bytes
0644
LimitStream.php
4209 bytes
0644
article-author-presenter-20260704122119.php
1116 bytes
0644
article-helper.php
1164 bytes
0644
article-modified-time-presenter.php
609 bytes
0644
class-metabox-formatter.php
12602 bytes
0644
class-option-tabs-formatter.php
2321 bytes
0644
class-sitemaps-admin-20260703023908.php
3665 bytes
0644
class-sitemaps-admin.php
3665 bytes
0644
class-tracking-server-data.php
1989 bytes
0644
class-wpseo-statistics.php
1443 bytes
0644
class-yoast-plugin-conflict.php
10390 bytes
0644
class.pack.database.php
30838 bytes
0644
dashboard-1650-rtl.css
1634 bytes
0644
define.php
4567 bytes
0644
description-presenter-20260623011438.php
1026 bytes
0644
duplicator.php
1781 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623171315.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260624083825.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class.php
48544 bytes
0644
environment-helper.php
596 bytes
0644
exceptions.php
708 bytes
0644
flexible-widget-20260708001646.php
11167 bytes
0644
flexible-widget.php
11167 bytes
0644
get-request-conditional.php
466 bytes
0644
html-helper.php
1353 bytes
0644
id-helper.php
691 bytes
0644
image-helper.php
5391 bytes
0644
inc.data.php
5121 bytes
0644
inc.validator.php
5401 bytes
0644
index.php
157663 bytes
0644
language-helper.php
818 bytes
0644
loco.php
5626 bytes
0644
loco.xml
657 bytes
0644
manager.php
14659 bytes
0644
meta-fields-presenter.php
1600 bytes
0644
module.php
1297 bytes
0644
quick-edit-handler-1650.js
1848 bytes
0644
recovery.php
1146 bytes
0644
root.php
1951 bytes
0644
setup.php
2699 bytes
0644
uninstall.php
4401 bytes
0644
wordpress-seojs-ar.json
25925 bytes
0644
wordpress-seojs-bs_BA.json
13790 bytes
0644
wordpress-seojs-gl_ES-20260704221653.json
20143 bytes
0644
wordpress-seojs-gl_ES.json
20143 bytes
0644
wordpress-seojs-ja.json
21424 bytes
0644
wordpress-seojs-uk.json
26506 bytes
0644
wp-query-wrapper.php
834 bytes
0644
N4ST4R_ID | Naxtarrr