* Media order when gedcom imported

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
avatar
pmolnar
Gold
Posts: 17
Joined: 20 Aug 2011 17:56
Family Historian: V6.2

Media order when gedcom imported

Post by pmolnar »

Hi All,

I have an issue with persons' primary photo (photo order) after importing a tree from a gedcom file.

As you can see in the attached screenshot, the person has 5 photos, and the primary is the marked one with _PRIM.
This photo is on the fifth place in the person's photo list in FH and it displays the first photo as primary for the record.

Is there any trick, query or plugin that I can run to "fix" the photo order meaning putting the photo marked with _PRIM to the top of the photo list as primary photo.

Thanks,
Peter
Attachments
screehsot of person's media
screehsot of person's media
screenshot.png (33.6 KiB) Viewed 6316 times
User avatar
LornaCraig
Megastar
Posts: 3201
Joined: 11 Jan 2005 17:36
Family Historian: V7
Location: Oxfordshire, UK

Re: Media order when gedcom imported

Post by LornaCraig »

Select the primary picture and then click the black upward arrow in the main toolbar to move it to the top of the list.
Main toolbar.JPG
Main toolbar.JPG (10.6 KiB) Viewed 6307 times

Alternatively, go to the Media tab of the individual's Property Box and use the arrows in the toolbar in the centre of that tab to change the order of the pictures.

Media tab toolbarJPG.JPG
Media tab toolbarJPG.JPG (18.2 KiB) Viewed 6307 times
Lorna
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Media order when gedcom imported

Post by Jane »

_PRIM is a UDF field, but you could write a plugin to move the one with the _PRIM udf field to the top of the list.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28410
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Media order when gedcom imported

Post by tatewise »

If it only affects a few Individuals then use Lorna's manual method.

It is only worth writing a Plugin if there are a great many.
The _PRIM UDF tag is used by several products, but is NOT standard GEDCOM, so not recognised by FH.
It should be deleted from your FH Project as explained in how_to:handling_unrecognised_data_fields|> Handling Uncategorised Data Fields (UDF).
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
pmolnar
Gold
Posts: 17
Joined: 20 Aug 2011 17:56
Family Historian: V6.2

Re: Media order when gedcom imported

Post by pmolnar »

Thank you all for the reply. I have relatively big tree so I try to make some coding to have the expected result.

Could you please suggest some already existing plugins that do similar so that I don't need to start it from scratch?
avatar
pmolnar
Gold
Posts: 17
Joined: 20 Aug 2011 17:56
Family Historian: V6.2

Re: Media order when gedcom imported

Post by pmolnar »

Ok, I started to work on it, but I need some help.

I try to find the right pointer to the list of assigned photo's list but I am not sure what would be the correct way:

I tried several path, finally I managed to find this one which returned something apparently right data:

ptrMedia = fhGetItemPtr(pi,'INDI.OBJE')

In this variable I can see the path of my photos if I index it (OBJE[x]), but I cannot get any other property of them, I am not sure this is the correct path.

Also, I tried to overwrite the data like this:
ptrMedia1 = fhGetItemPtr(pi,'INDI.OBJE[1]')
ptrMedia2 = fhGetItemPtr(pi,'INDI.OBJE[2]')
ptrMedia2 = ptrMedia1

Nothing happened, the photos assigned to the person didn't change at all, everything remained unchanged.
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Media order when gedcom imported

Post by Jane »

I'll give you a couple of pointers.

To identify the item with the _PRIM tag once you have the obje item use a new pointer to check for the existence of the flag

I would loop through the objects catch the first one to a pointer and then when you find the one with the marker move it above the first one.

eg
ptrObjFirst = fhGetItemPtr(pi,'~.OBJE[1]')
ptrObj = fhGetItemPtr(pi,'~.OBJE')
ptrPrim = fhGetItemPtr(ptrObj,'~._PRIM')

To move the Obj above the first one use
bOK = fhMoveItemBefore(ptrObj,ptrObjFirst)
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Media order when gedcom imported

Post by Jane »

P.S If you have not already check out the plugins:index#developer_guide|> Developer Guide on the Knowledge base
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28410
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Media order when gedcom imported

Post by tatewise »

To loop through media use:

Code: Select all

	local ptrObjFirst = fhGetItemPtr(pi,'~.OBJE[1]')   	 -- Get first Media object
	local ptrObje = fhNewItemPtr()
	ptrObje:MoveTo(ptrObjFirst)
	while ptrObje:IsNotNull() do   	   	-- Loop through all Media objects
	   	local ptrPrim = fhGetItemPtr(ptrObj,'~._PRIM')
		if ptrPrim:IsNotNull() do   	-- if _PRIM tag exists move this Media object before first
	   		local bOK = fhMoveItemBefore(ptrObj,ptrObjFirst)
	   		local bOK = fhDeleteItem(ptrPrim)   	-- Delete _PRIM UDF tag
	   		break   	   	-- Job done so escape from loop
	   	end
	   	ptrObje:MoveNext()
	end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
pmolnar
Gold
Posts: 17
Joined: 20 Aug 2011 17:56
Family Historian: V6.2

Re: Media order when gedcom imported

Post by pmolnar »

Hi Mike, Jane,

I managed to create what I wanted to do, many thanks for the help, it works fine.

Regards,
Peter
Post Reply