Skip Navigation

[Resolved] Repeating image field output raw does not display correctly if used in “a href”

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user is building links using HTML and Toolset shortcodes for the URL. The shortcode does not return the expected URL.

Solution:
The issue is somehow caused by Elementor. Maybe Elementor does some preprocessing of its modules before evaluating Toolset shortcodes. The shortcodes works as expected inside a Toolset Content Template.

As a workaround, create the link inside a content template, and include the content template inside the Elementor template. Check this reply: https://toolset.com/forums/topic/repeating-image-field-output-raw-does-not-display-correctly-if-used-in-a-href/#post-1910861

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/

This support ticket is created 4 years, 1 month 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by justinB-3 4 years, 1 month ago.

Assisted by: Jamal.

Author
Posts
#1910145

I am trying to: display the image field URL into an "a href" tag
i.e

Link to a page where the issue can be seen: hidden link
password: toolset

I expected to see:


Instead, I got:


I find it confusing because if it's just displayed outside the a href, it shows up normally.
This is the code we're using.

<div class="specialty-gallery clearfix">[wpv-for-each field='wpcf-gallery']
<div class="image-wrapper">[types field='gallery' alt='%%ALT%%' title='%%TITLE%%' width='187' height='125' align='none' resize='crop'][/types]<br>
URL outside of a href (works OK) = [types field='gallery' output='raw'][/types]
</div>
[/wpv-for-each]

#1910249

Hello and thank you for contacting the Toolset support.

You need to use the wpv-post-field shortcode instead of the types shortcode inside wpv-for-each. Try this:

<div class="specialty-gallery clearfix">
	[wpv-for-each field='wpcf-gallery']
		<div class="image-wrapper">
			<a class="ngg-fancybox" href="[wpv-post-field name='gallery']" rel="gallery_[wpv-post-id]">
				[types field='gallery' alt='%%ALT%%' title='%%TITLE%%' width='187' height='125' align='none' resize='crop'][/types]
			</a>

			URL outside of a href (works OK) = [types field='gallery' output='raw'][/types]
		</div>
	[/wpv-for-each]

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153482

If this does not help, allow me temporary access to your site to check this further. Let me know what View/content template your are working on. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1910345

Thank you for your feedback, but the credentials are not working for me, can you double-check and update them in your next message.

#1910861

Thank you for the credentials. I was able to log in and check this issue. It seems that the issue is somehow caused by Elementor. Maybe Elementor does some preprocessing of its modules before evaluating Toolset shortcodes.

In fact, if we moved that code to a content template and we use the content template inside the Elementor template, it works. I did a small test with this content template hidden link

<div class="specialty-gallery clearfix">
  [wpv-for-each field='wpcf-gallery']
  	<div class="image-wrapper">
      <a class="ngg-fancybox" href="[types field='gallery' output='raw'][/types]" rel="gallery_[wpv-post-id]">
        [types field='gallery' alt='%%ALT%%' title='%%TITLE%%' width='187' height='125' align='none' resize='crop'][/types]
      </a>
      
      URL outside of a href (works OK) = [types field='gallery' output='raw'][/types]
  	</div>
  [/wpv-for-each]
</div>

Then I used it inside Elementor with:

[wpv-post-body view_template="toolset-support-test"]

And it gives the expected results. Check this screenshot hidden link

I could've escalated this to our 2nd Tier for more analysis, but as it involves a 3rd party execution environment(Elementor Text Widget) and it works with our content templates, I am pretty sure it won't be handled further. You might want to reach the Elementor team for additional assistance about this.

I hope this helps. Let me know if you have any questions.

#1910901

My issue is resolved now. Thank you!