Skip Navigation

[Resuelto] List of files with weight

This support ticket is created hace 1 año, 2 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por Minesh hace 1 año, 1 mes.

Asistido por: Minesh.

Autor
Mensajes
#2646461
Captura de pantalla 2023-09-22 112017.jpg

Hi, I have created a list of files to download and I want to show the weight of each file.
I have added a custom function in Toolset to manage a shortcode to display the data. The code is as follows:

/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
add_shortcode('display-pdf-size', function($atts){
global $post;
$atts = shortcode_atts( array(
'pdf_url' =>'' ,
'meta_name' => 'size',
), $atts );

$res = '';

$attachment_id = attachment_url_to_postid($atts['pdf_url']);

$file = get_attached_file($attachment_id);

switch($atts['meta_name']){
case 'size':
$res = size_format(filesize( $file ));
break;
}
return $res;
});

I have created a view of the download repeatable field to display the download file listing. In the link name it has file name and the shortcode to show the file weight.

<wpv-loop>
<div class="icon-lista">
[types field='nombre-archivo-desc'][/types] - [display-pdf-size meta_name="size" pdf_url="[types field='descarga' output='raw'][/types]"]
</div>
</wpv-loop>

The problem is that it does not show me the data and the shortcode appears.

What could be happening?

Thanks for your help.

#2646565

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to know have you activated the code snipped you added? If yes:

Then I will require admin access details and problem URL where I can see the issue.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2647133

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

As I suspected with my previous reply where I shared you should make sure that the code snippet should be active and when I logged in to the admin and when I checked the code snippet you added, it was not active.

I've activated the code snippet now.

Further - when I checked the problem URL you shared in the backend:
- enlace oculto

In backend:
- enlace oculto

I see there is no PDF uploaded to the repeating field group. Can you please first try to upload the PDF files to the repeating field group first and let me know after that if you able to see the file size or not.

#2647801

Thanks Minesh, I checked to make sure it was active but I got confused. Thanks for your help. I have tried adding a PDF and its weight is displayed.
Please de URLs in private in the answers.
Thank you and have a nice day.

#2647859

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Glad to know that the solution I shared help you to resolve your issue.

You're welcome to mark resolve this ticket.