Skip Navigation

[Resolved] Change the last 4 charectors of a field shortcode to another value

This support ticket is created 3 years, 3 months ago. 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.

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)

This topic contains 11 replies, has 2 voices.

Last updated by Minesh 3 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2176787

Tell us what you are trying to do?

I need to display images of a PDF with the URL of the pdf, but I need to replace the '.pdf' ending with '-pdf.jpg'
The shortcode I have for the PDF is [wpv-post-url] inside my Toolset View. Do you know how I can edit the output URL to change the ending as described above?

I tried using a plugin to accomplish the same thing but had issues with it, so any help you could provide is gretly appreciated.

#2177283

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You will have to write the custom shortcode that replace the last 4 characters of your URL to the characters you want.

Can you please share problem URL and admin access details and tell me with what field you want to replace the characters?

*** 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.

#2178265

The fatal error on the site is logging the following error:

[24-Sep-2021 06:56:33 UTC] PHP Fatal error: Cannot redeclare convert_date_fields_func() (previously declared in /home/pdccpanel/public_html/wp-content/toolset-customizations/convert-jci-hp-date.php:12) in /home/pdccpanel/public_html/wp-content/toolset-customizations/cutom-pdf-url.php on line 22

Please advise, thank you.

#2178269

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share link on what page you added the view you are talking about?

#2178283

Of course!
hidden link

And thank you for quickly solving the critical error

#2178289

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When I print the [wpv-post-url] shortcode just aboe every loop item - I do not see any of URL having .pdf.

Can you please confirm what URL I've to target?

#2178953

It seems that the [wpv-post-url] for these media items is loading the post URL which is different than the File URL that the post URL redirects to on click.
What we need to edit is actually the file URL that the items redirect to. Do you know if there is a field shortcode that loads that?

I've made a duplicate of the View called 'Research and Reports - Duplicate for testing' so we can make changes without affecting the frontend as the site is currently under review.
Thank you for your help!

#2180621

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I see you are using the PDF thumbnail plugin and the redirection happened to PDF thumbnail due to that. You will require to check with the plugin support about how you can display the PDF thumbnail within the view's loop.

#2180653

Yes, this code would be to replace the Thumbnail plugin as I found some issues with it.
In this page I inserted the duplicate of the View so we can make changes: hidden link

The thumbnail was being displayed because the View Template is using this as the SRC URL: [wpv-post-featured-image size="full" output="url"], ideally we'd replace that shortcode with one that takes the URL of the PDF and changed the .pdf ending.
My apologies If I didn't understand you correctly.

#2180787

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I do not see anything with the test URL you shared:
=> hidden link

In addition to that, I tried changing image URL from jpg to pdf:
=> hidden link
To:
=> hidden link

but it does not load any PDF file. As you already aware that Toolset does not offer any feature related to PDF and what function you are assuming that chafing the image url from .jpg to .pfd is not actually working.

#2180809

That's likely because of the Custom Code that was added to Toolset for filtering the View Items referencing the original view ID, so duplicating the View may mean that the custom code needs to be edited?

Aplogies if I caused confusion.
To help clarify, we are not trying to edit the .jpg ending of the attached thumbnails to .pdf, we are trying to change the .pdf extension of the PDF to '-pdf.jpg'
So for the images above, you'll see the actual PDF media item is at:
hidden link
and we want to edit the URL ending to the following:
hidden link

Both the links above should be working right now, and this would remove the dependence we currently have on the PDF Thumbnails plugin.
Thank you for your patience and all your help, you've been wonderful!

#2180849

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

But the thing is that the image that has been displayed is:
=> hidden link

Not:
=> hidden link

I'm not sure how its going to work as every file name is different. Maybe you should try the following code that is what you want to display I believe:
=> https://toolset.com/forums/topic/displaying-the-pdf-thumbnail-instead-of-plain-link-in-loop/#post-918344