Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions classes/models/FrmApplicationTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,48 @@ public static function init() {
'frm_application_data_keys',
array( 'key', 'name', 'description', 'link', 'categories', 'views', 'forms' )
);
self::$keys_with_images = self::get_template_keys_with_local_images();
self::$keys_with_images = array_merge(
self::get_template_keys_with_local_png_images(),
self::get_template_keys_with_local_webp_images()
);
self::$categories = array();
}

/**
* Newer templates now use .webp files instead of .png.
*
* @since x.x
*
* @return array<string>
*/
private static function get_template_keys_with_local_webp_images() {
return array(
'member-directory',
'link-in-bio-instagram',
'letter-of-recommendation',
'invoice-pdf',
'freelance-invoice-generator',
'contract-agreement',
'charity-tracker',
'certificate',
'testimonials',
);
}

/**
* Return the template keys that have embedded images. Otherwise, we want to avoid trying to load the URL and use the placeholder instead.
*
* @return array<string>
*/
private static function get_template_keys_with_local_images() {
private static function get_template_keys_with_local_png_images() {
return array(
'business-hours',
'faq-template-wordpress',
'restaurant-menu',
'team-directory',
'product-review',
'real-estate-listings',
'business-directory',
);
}

Expand Down Expand Up @@ -153,6 +178,7 @@ function ( $category ) {
}//end foreach

$application['hasLiteThumbnail'] = in_array( $application['key'], self::$keys_with_images, true );
$application['isWebp'] = in_array( $application['key'], self::get_template_keys_with_local_webp_images(), true );

if ( ! array_key_exists( 'url', $application ) ) {
$purchase_url = $this->is_available_for_purchase();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/applications/thumbnails/certificate.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/applications/thumbnails/invoice-pdf.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/applications/thumbnails/testimonials.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion js/admin/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@

function getCardContent() {
const thumbnailFolderUrl = getUrlToApplicationsImages() + 'thumbnails/';
const filenameToUse = data.hasLiteThumbnail ? data.key + '.png' : 'placeholder.svg';
const filenameToUse = data.hasLiteThumbnail ? data.key + ( data.isWebp ? '.webp' : '.png' ) : 'placeholder.svg';
Comment thread
Crabcyborg marked this conversation as resolved.
return div({
className: 'frm-application-card-image-wrapper',
child: img({ src: thumbnailFolderUrl + filenameToUse })
Expand Down
2 changes: 1 addition & 1 deletion js/form-templates.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/src/form-templates/elements/applicationTemplatesElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export function createApplicationTemplates( applications ) {
* @return {HTMLElement} Element representing a single application template.
*/
function createTemplateItem( template ) {
const { name, key, hasLiteThumbnail } = template;
const { name, key, hasLiteThumbnail, isWebp } = template;
const thumbnailURL = hasLiteThumbnail ?
`${thumbnailBaseURL}/${key}.png` :
( isWebp ? `${thumbnailBaseURL}/${key}.webp` : `${thumbnailBaseURL}/${key}.png` ) :
`${thumbnailBaseURL}/placeholder.svg`;

return tag( 'li', {
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/e2e/Form Templates/FormTemplates.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe("Form Templates page", () => {
.within(() => {
cy.get('div.frm-form-templates-item-icon img')
.should('have.attr', 'src')
.and('include', 'placeholder.svg');
.and('include', 'business-directory.png');
Comment thread
Crabcyborg marked this conversation as resolved.

cy.get('span.frm-meta-tag.frm-orange-tag')
.should('have.text', 'Ready Made Solution');
Expand Down