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

Document splash screen generation for iOS? #1203

Open
nisbet-hubbard opened this issue Nov 8, 2024 · 3 comments
Open

Document splash screen generation for iOS? #1203

nisbet-hubbard opened this issue Nov 8, 2024 · 3 comments

Comments

@nisbet-hubbard
Copy link

Even after iOS 15.4, splash screens for various resolutions still have to be generated and explicitly defined: elegantapp/pwa-asset-generator#892.

Would it be possible for this to be better documented, especially regarding how to glue pwa-asset-generator with this plugin?

@westonruter
Copy link
Collaborator

I am not familiar with pwa-asset-generator so I wouldn't be able to write this documentation with my current knowledge.

@nisbet-hubbard
Copy link
Author

Sure, pwa-asset-generator is only one possible workaround.

So the bigger issue seems to be that there's not yet an easy way in this plugin to deal with Safari's current requirement for a variety of splash screen image sizes. And perhaps it's a behaviour one may or may not want to support.

@westonruter
Copy link
Collaborator

Here's the existing Safari-specific logic:

<?php
$display = isset( $manifest['display'] ) ? $manifest['display'] : '';
switch ( $display ) :
case 'fullscreen':
case 'minimal-ui':
case 'standalone':
?>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<?php
// Use the smallest icon from the manifest as the default Apple touch startup image.
$icons = isset( $manifest['icons'] ) ? $manifest['icons'] : array();
usort(
$icons,
static function ( $a, $b ) {
$a_size = isset( $a['sizes'] ) ? (int) strtok( $a['sizes'], 'x' ) : 0;
$b_size = isset( $b['sizes'] ) ? (int) strtok( $b['sizes'], 'x' ) : 0;
return $a_size - $b_size;
}
);
$icon = array_shift( $icons );
$images = array();
if ( ! empty( $icon ) ) {
$images[] = array( 'href' => $icon['src'] );
}
/**
* Filters splash screen images for Safari on iOS.
*
* @param array $images {
* Array of splash screen images and their attributes.
*
* @type array ...$0 {
* Array of splash screen image attributes.
*
* @type string $href URL of splash screen image. Required.
* @type string $media Media query for when the splash screen image should be used.
* }
* }
*/
$images = apply_filters( 'apple_touch_startup_images', $images );
foreach ( $images as $image ) {
if ( is_array( $image ) && isset( $image['href'] ) && esc_url( $image['href'], array( 'http', 'https' ) ) ) {
printf( '<link rel="apple-touch-startup-image" href="%s"', esc_url( $image['href'] ) );
if ( isset( $image['media'] ) ) {
printf( ' media="%s"', esc_attr( $image['media'] ) );
}
echo ">\n";
}
}
break;
endswitch;
?>

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

No branches or pull requests

2 participants