thanks,

Got it:


#set($test2Doc = 
$xwiki.getDocument('Sandbox.testImageCount').getTranslatedDocument())

#foreach($imageBlock in 
$test2Doc.getDocument().getXDOM().getBlocks("class:ImageBlock", "DESCENDANT"))
   $imageBlock.getReference().reference
#end

But can I do the same for a Blog attribute: (extract) ?



Gerritjan Koekkoek
Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
Visit our website<http://www.cdlsworld.org>
Facebook<https://www.facebook.com/gerritjan.koekkoek>
email<gerrit...@cdlsworld.org>





________________________________
From: users <users-boun...@xwiki.org> on behalf of Thomas Mortagne 
<thomas.morta...@xwiki.com>
Sent: 05 December 2016 16:49
To: XWiki Users
Subject: Re: [xwiki-users] Content conversion

On Mon, Dec 5, 2016 at 4:42 PM, Gerritjan Koekkoek
<gerrit...@cdlsworld.org> wrote:
> You are right; renaming Sandbox.testImageCount as a terminal page changed the 
> situation. getting closer
>
>
> The output of:
>
> #set($test2Doc = 
> $xwiki.getDocument('Sandbox.testImageCount').getTranslatedDocument())
>
> {{{$test2Doc.content}}}
>
> $test2Doc.getDocument().getXDOM().getBlocks("class:ImageBlock", 
> "DESCENDANT").class.name
>
> {{{$test2Doc.getDocument().getXDOM().getBlocks("class:ImageBlock", 
> "DESCENDANT")}}}
>
> is:
>
> Sandbox.testImageCount
>
> Dit is text Dit is text Dit is text [[image:logo-amc.png]] Dit is textDit is 
> text Dit is textDit is text Dit is textDit is text Dit is textDit is text Dit 
> is textDit is text Dit is textDit is text Dit is text
> java.util.ArrayList
> [org.xwiki.rendering.block.ImageBlock@bd3e4fc7]
>
>
> But how can I transform this to a list of images?

You can get the reference of the image using method
ImageBlock#getReference(). It will give you an instance of
ResourceReference (actually in this use case it should be a
AttachmentResourceReference which extends ResourceReference probably).

See 
http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/org/xwiki/rendering/xwiki-rendering-api/8.4.1/xwiki-rendering-api-8.4.1-javadoc.jar/!/index.html
for more details.

>
>
>
> Gerritjan Koekkoek
> Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
> Visit our website<http://www.cdlsworld.org>
> Facebook<https://www.facebook.com/gerritjan.koekkoek>
> email<gerrit...@cdlsworld.org>
>
>
>
> ________________________________
> From: users <users-boun...@xwiki.org> on behalf of Thomas Mortagne 
> <thomas.morta...@xwiki.com>
> Sent: 05 December 2016 16:32:32
> To: XWiki Users
> Subject: Re: [xwiki-users] Content conversion
>
> Are you sure "Sandbox.testImageCount'" is the right reference ? Do you
> have something when you print $test2Doc.content ?
>
> If "Sandbox.testImageCount" does not exist maybe you need to try
> "Sandbox.testImageCount.WebHome".
>
> On Mon, Dec 5, 2016 at 4:24 PM, Gerritjan Koekkoek
> <gerrit...@cdlsworld.org> wrote:
>> I fail to understand the rendering framework suggestion
>>
>> #set($test2Doc = 
>> $xwiki.getDocument('Sandbox.testImageCount').getTranslatedDocument())
>>
>> $test2Doc.getDocument().getXDOM().getBlocks("class:ImageBlock", "DESCENDANT")
>>
>> Gives me a empty array, although the source document  looks like this (XWiki 
>> 2.1)
>>
>> Dit is text
>> Dit is text
>> Dit is text
>>
>> [[image:logo-amc.png]]
>> Dit is textDit is text
>> Dit is textDit is text
>> Dit is textDit is text
>> Dit is textDit is text
>> Dit is textDit is text
>> Dit is textDit is text
>>
>> Note that I would like to extract from this: "logo-amc.png"
>>
>>
>> Gerritjan Koekkoek
>> Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
>> Visit our website<http://www.cdlsworld.org>
>> Facebook<https://www.facebook.com/gerritjan.koekkoek>
>> email<gerrit...@cdlsworld.org>
>>
>>
>>
>> ________________________________
>> From: users <users-boun...@xwiki.org> on behalf of Thomas Mortagne 
>> <thomas.morta...@xwiki.com>
>> Sent: 02 December 2016 11:41:40
>> To: XWiki Users
>> Subject: Re: [xwiki-users] Content conversion
>>
>> On Fri, Dec 2, 2016 at 11:02 AM, Gerritjan Koekkoek
>> <gerrit...@cdlsworld.org> wrote:
>>> Is it possible to get what images are inside a content page.
>>>
>>> Note I do not mean Attached images, but the images displayed inline in the 
>>> content
>>
>> You can parse any content into XDOM and then search for ImageBlock in
>> it. See 
>> http://rendering.xwiki.org/xwiki/bin/view/Main/GettingStarted#HExamples.
>>
>>>
>>>
>>> Is it also possible to display the content without these images, as plain 
>>> Text (also remove the wiki-markup )
>>
>> We usually use plain text rendered (id "plain/1.0") for this.
>> Basically you use rendering framework to parse the content and then
>> serialize it with a special plain text renderer.
>>
>>>
>>>
>>> Gerritjan Koekkoek
>>> Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
>>> Visit our website<http://www.cdlsworld.org>
>>> Facebook<https://www.facebook.com/gerritjan.koekkoek>
>>> email<gerrit...@cdlsworld.org>
>>>
>>>
>>>
>>
>>
>>
>> --
>> Thomas Mortagne
>
>
>
> --
> Thomas Mortagne



--
Thomas Mortagne

Reply via email to