Problem with ^empty values for image variety URL kewyords


(Talk) #1

Hi all, I've been trying to print images in layouts only if they exist and contain a certain a variety - otherwise they're to be replaced by a default image. There's many ways to do this, but the most efficient way for me has been to use:

%asset_thumbnail_v_XXX_url^empty:./?a=XXX%

This only returned a seemingly empty string when the variety didn't exist, which after checking with charcount, I found was 21 characters long. I urlencoded the result and found out that it literally returned the string: "%image_v_XXX_url%" - which won't actually render on the front end because it's empty, however this means that whenever you use image_variety_XXX_url, it will never be able to be modified with ^empty even though it's technically empty.

 

I've also tried ^as_asset modifier without success: %asset_thumbnail_assetid^as_asset:image_v_XXX_url^empty:./?a=XXX%

 

This is okay, because I've now swapped out ^empty to ^replace and can now get my default image in there, but can I ask, is this likely to be a bug? I'd like to know, as my fix will stop working if it is a bug and is fixed.

 

Here's what I've had to implement for now:

%asset_thumbnail_v_XXX_url^replace:.*image_v_XXX_url.*:./?a=XXX%

(Anthony) #2

I'm guessing here... but because its coded so the variety name is part of the actual keyword, if that variety doesnt exist you have essentially specified an invalid keyword, and I think %anyoldjunkthatsinvalid% that the keyword parser doesnt recognise probably gets left in the output string unchanged? So I'm guessing its not a bug as such.

 

What would seem to be needed is some way to test if a particular variety exists for an image. I suppose there could be a keyword modifier approach... I can think of a few options like ^varietyexists:dothis:dotheother or ^varietysubstitute:fallbackname

 

But maybe a better approach would be in a conditional keywords section of a paint layout? I just had a quick look and cant see a conditional test specific to an image variety existing, that would have been ideal. I expect you could do it with the regexp options though.


(Talk) #3

Hi Anthony, I really like the idea of the variety exists modifier, I think that would add a heap of functionality to image varieties.

I use a regex condition to print these image varieties if they exist at page level, but for listing results, this keyword isn’t useful as the only option that offers a match is globals_asset_


(Anthony) #4

Not sure if this helps... but a trick I picked up on these forums a while ago which helped me... I have asset listings where the type format includes just something like %asset_contents_paint_18009% and then in that paint layout I seem to have access to all the keywords I'd need, including for conditional tests. Might not work for you if your scenario is a bit different. I wasn't using it for image variety stuff like you are.


(Talk) #5

Thanks Anthony, yes I use paint layouts for all type formats, but won't globals_asset_X access the currently viewed page's values always? The only keyword capable of running a regex check against an image variety is 'globals_asset_' as it's the only open-ended option.


(Anthony) #6

Oh! Yes, I just looked and see your problem. In my case all my regex checks are either on "standard" properties that are in the dropdown or mostly on "asset_metadata_" which is an open ended option that gives me a box to type in any metadata name. So really they should have an entry specific to image varieties, or a more general asset_ that lets you type anything in. You could submit an enhancement request, it seems an odd omission.