- This topic has 9 replies, 2 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
March 18, 2019 at 6:19 pm #842796
Matthew
hi Tom,
There’s something causing the disallowing of an attachment page to be the child of another attachment page.
I tested this a fair bit earlier on and WordPress does permit parent/child relationship for attachments (and not just images attached to regular pages and posts). Had it working in Enfold but have left that theme for other reasons. It also works in the default WordPress themes i.e. TwentyFourteen.
To demonstrate what I mean simply there are two random test images with filenames of:
1) atmosphere-processors-plain-1
2) possessed-girl-exorcism-2#2 is attached or uploaded to #1 i.e. it’s child
However when I click ‘View’ for the child image in WP Media Library I get redirected to the parent page and the permalink is:
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/#main/possessed-girl-exorcism-2/#main
For comparison, when I click View in TwentyFourteen the correct child page is shown and the permalink is:
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-2/
This linking is an essential thing for me as I have built image variations that connect to each other, so I’m hoping this can be able to be remedied.
Not sure if it’s the #main anchor interfering, got a feeling its something else, but could be wrong.
thanks again,
March 19, 2019 at 9:07 am #843506Tom
Lead DeveloperLead DeveloperHi there,
#2 is attached or uploaded to #1 i.e. it’s child
How are you doing this? Can you show me a screenshot?
Does this method work in the TwentyNineteen theme?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 19, 2019 at 8:37 pm #844017Matthew
Hi Tom, thanks for the followup,
Images:
#1) atmosphere-processors-plain-1
#2) possessed-girl-exorcism-1So I insert an image directly from the attachment editing screen using a custom field.
Image #2 is inserted while in edit screen of #1.
Screenshot 1Then check the image in the media library and it stays ‘Unattached’ because the upload in the previous step was inside the attachment edit screen i.e. not inside a regular page. If I click ‘Attach’ here it only provides option to attach to a page or post so I go to next step.
Screenshot 2So go to the attachment editing screen this time for #2 image the one I just uploaded to #1. Scroll to Parent Info currently on 0.
Screenshot 3I enter a unique number for Parent Info, which is 3715 (#1 images unique number) and click Update. It makes #1 image the parent
Screenshot 4Back at media library the ‘Uploaded to’ column now shows the #1 image for its parent
Screenshot 5On the front end the inserted image on #1 attachment page is set to link to the #2 attachment page. But this link now does not work
Screenshot 6On the front end on #2 attachment page as mentioned before, the code that connects back to the parent also does not function. I also just tried this on TwentyNineteen and it does work for that theme correctly i.e. this code:
the_post_navigation( array( 'prev_text' => _x( '<span class="meta-nav">Published in</span><br><span class="post-title">%title</span>', 'Parent post link', 'twentynineteen' ), ) ;
Plugins used:
Advanced Custom Fields (Screenshot 1); the only way to upload/insert media on an attachment page.
Media Library Assistant: I think this adds the change parent field (Screenshot 3, Screenshot 4) but the standard WP Media Library (Screenshot 5) shows the result under ‘Uploaded to’ columnThanks,
March 20, 2019 at 9:06 am #844702Tom
Lead DeveloperLead DeveloperHmm, ok, I’m not quite understanding 100% yet.
Is the issue that you can’t access the child attachment? Or is it that the post navigation (
the_post_navigation()
function) isn’t working? I’ve never worked with child and parent attachments, so the concept is new to me.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 20, 2019 at 6:20 pm #845092Matthew
Yes that’s right. When I attach one image to another image the child attachment can’t be accessed.
After attaching them I go to the Media Library and click ‘View’ on the child image. But it goes to the parent and the URL is:
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/#main/possessed-girl-exorcism-01/#main
i.e. it can’t get to ‘possessed-girl-exorcism-01’
Whereas in TwentyNineteen I correctly get the child and the URL is:
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-01/
And this is what Media Library Assistant does when I click ‘View’ on the child image after attaching them:
first it correctly goes to the child image looking for it…
http://www.imjexa.com/?attachment_id=3459
but it can’t find it so it then redirects to the parent…
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/
Whereas in TwentyNineteen after looking for it then manages to find it…
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-01/
Media Library Assistant is virtually identically the media library again but it has some beefed up features.
If I manually enter or paste the URL
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-01/it goes to the correct child page and the function
the_post_navigation
in the child attachment works properly to bring user back to the parent. But the linking setup in the code does not. Looking at those URL’s it could be just the #main ID or anchor interfering? How can I suppress the ID to test it?thanks,
Realised I forgot to provide password for ‘Hide my Site’ plugin. Did this block entry to those screen captures? I just sent it to you thru your Contact form in case.
March 21, 2019 at 8:16 am #845716Tom
Lead DeveloperLead DeveloperVery strange, I can’t imagine what GP would be doing differently than a core theme when it comes to something like this.
Does Media Library Assistant have active support? If it does, any chance we can check with them on what would possibly cause this? Any sort of hint would help, as right now I’m not sure where to look.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 22, 2019 at 10:36 pm #847153Matthew
Looking at those URL’s it could be just the #main ID or anchor interfering? How can I suppress the ID to test it?
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/#main/possessed-girl-exorcism-01/#main
Vs other themes:
http://www.imjexa.com/test-1/atmosphere-processors-plain-1/possessed-girl-exorcism-01/
This is what it’s doing differently. Could you at least tell me what this is that’s coming from the template code? It look like the cause
I removed these from
attachment.php
(based onsingle.php
andcontent-single.php
) without any difference:id="main" <?php generate_do_element_classes( 'main' ); ?>
do_action( 'generate_before_main_content' );
I have also asked with the media library assistant.
thanks,
March 23, 2019 at 8:06 am #847547Tom
Lead DeveloperLead DeveloperTry adding this function to your site:
add_action( 'after_setup_theme', function() { remove_filter( 'attachment_link', 'generate_enhanced_image_navigation', 10, 2 ); } );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 26, 2019 at 12:44 am #849963Matthew
I was just about to give up and get someone to check it out. Then this. Boom!
March 26, 2019 at 8:05 am #850481Tom
Lead DeveloperLead DeveloperAwesome! 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.