在Blogger中,我支持我的网站功放,为此,在我的帖子中,我更改了所有<img
。
但在结构化数据中,我使用以下代码:
<?php
if (!defined('MY_AWS_AUTOLOADER_FILE_LOCATION')) {
// Replace /var/www/html/aws/aws-autoloader.php with wherever your actual file is
// Make sure you've already downloaded and unzipped the aws-autoloader.php file
// Can be found at http://docs.aws.amazon.com/aws-sdk-php/v3/download/aws.zip
define('MY_AWS_AUTOLOADER_FILE_LOCATION', '/var/www/html/aws/aws-autoloader.php');
}
if (!defined('MY_AWS_REGION_ID')) {
// Replace us-west-2 with whatever your actual region ID is
define('MY_AWS_REGION_ID', 'us-west-2');
}
if (!defined('MY_AWS_ACCESS_KEY_ID')) {
// Replace abcdefghijk with whatever your actual access key is
define('MY_AWS_ACCESS_KEY_ID', 'abcdefghijk');
}
if (!defined('MY_AWS_SECRET_ACCESS_KEY')) {
// Replace lmnopqrstuvwxyz123456789 with whatever your actual secret key is
define('MY_AWS_SECRET_ACCESS_KEY', 'lmnopqrstuvwxyz123456789');
}
// Set the required environmental variables in case they
// haven't already been set in .htaccess or elsewhere
putenv('AWS_ACCESS_KEY_ID=' . MY_AWS_ACCESS_KEY_ID);
putenv('AWS_SECRET_ACCESS_KEY=' . MY_AWS_SECRET_ACCESS_KEY);
// Register the s3:// stream wrapper
aws_register_stream_wrapper();
// Now, the URI of an S3 object can be accessed internally, without having assigned
// a special access token to it. Assuming your bucket's name is my-bucket and the
// object's file key inside that bucket is images/example.jpg you can build
// the object's URI like so, which would assign a value of
// s3://my-bucket/images/example.jpg
// to $object_uri (making it internally accessible via that same URI):
$object_uri = aws_render_s3_uri('my-bucket', 'images/example.jpg');
/**
* Registers the s3:// stream wrapper
*/
function aws_register_stream_wrapper() {
$region = MY_AWS_REGION_ID;
// Simple security checks in case someone has messed with something
// they shouldn't have
if (!empty($region) && is_string($region)) {
$client = aws_render_s3_client();
$client->registerStreamWrapper();
}
}
/**
* @param $version (string)
* The version of the AWS API to use
*
* @return (object)
* An AWS S3 client
*/
function aws_render_s3_client($version = 'latest') {
require_once(MY_AWS_AUTOLOADER_FILE_LOCATION);
$s3_client = new Aws\S3\S3Client([
'key' => MY_AWS_ACCESS_KEY_ID,
'secret' => MY_AWS_SECRET_ACCESS_KEY,
'region' => MY_AWS_REGION_ID,
'version' => $version,
]);
return $s3_client;
}
/**
* @param $bucket (string)
* The name of the AWS bucket in which $file_key resides
*
* @param $file_key (string)
* The name of the file to be retrieved, relative to the AWS bucket
*
* @return (string)
* The URL to an AWS S3 object URL using the s3:// stream wrapper
*/
function aws_render_s3_uri($bucket, $file_key) {
$uri = "s3://{$bucket}/{$file_key}";
return $uri;
}
&#13;
答案 0 :(得分:1)
在很多论坛上搜索了很多论坛之后,我找到了我的问题的解决方案。在amp guideline使用NoScript后使用<amp-img
。
<amp-img src="images/sunset.jpg"
width="264"
height="195">
<noscript>
<img src="images/sunset.jpg" width="264" height="195" />
</noscript>
</amp-img>
这可以是你的Image的两个版本,一个是放大器,另一个是非放大器。